CSV Uploads
Import data from a CSV directly into Sift
Credentials
Before starting this section, ensure you have retrieved your API key and the appropriate Sift URL for your provisioned environment. Instructions on obtaining the API key and URL are available in the authentication section of the documentation.
Import CSVs with cURL
The configuration is a JSON object in the follow format:
To import data from a CSV:
- POST the configuration to
/api/v1/data-imports:upload
. If the request is valid, the endpoint will return an upload URL. - POST the data file to the upload URL. When the request finishes, the data is fully uploaded and will start ingesting.
Example
GZIP'd files are supported via the "content-encoding: gzip" request header.
Data Import from URL
The configuration is a JSON object in the follow format:
To import data from a URL:
- POST the configuration to
/api/v1/data-imports:url
. If the request is valid, the endpoint will return a 200 response code and begin ingesting the data. - GZIP'd files are supported via the "content-encoding: gzip" response header.
Example
CSV Upload Status
The 200 response from the upload itself only signals that the request to ingest has been submitted properly and does not indicate whether the data is ingested properly.
In order to check on the status of the upload, users can either poll
General status:
Specific upload status:
Examples:
General:
Specific:
CSV Configuration
The CSV configuration is a JSON object in the following format:
Columns not specified in the configuration are not ingested.
Time Formats
You can specify the following time formats:
Absolute
TIME_FORMAT_ABSOLUTE_RFC3339
: Example2023-01-02T15:04:05Z
TIME_FORMAT_ABSOLUTE_DATETIME
Example:2023-01-02 15:04:05
TIME_FORMAT_ABSOLUTE_UNIX_SECONDS
: Seconds since the unix epoch.TIME_FORMAT_ABSOLUTE_UNIX_MILLISECONDS
: Milliseconds since the unix epoch.TIME_FORMAT_ABSOLUTE_UNIX_MICROSECONDS
: Microseconds since the unix epoch.TIME_FORMAT_ABSOLUTE_UNIX_NANOSECONDS
: Nanoseconds since the unix epoch.
Relative
TIME_FORMAT_RELATIVE_NANOSECONDS
TIME_FORMAT_RELATIVE_MICROSECONDS
TIME_FORMAT_RELATIVE_MILLISECONDS
TIME_FORMAT_RELATIVE_SECONDS
TIME_FORMAT_RELATIVE_MINUTES
TIME_FORMAT_RELATIVE_HOURS
Data Types
You can specify the following data types:
CHANNEL_DATA_TYPE_DOUBLE
: A double precision floating point number.CHANNEL_DATA_TYPE_FLOAT
: A single precision floating point number.CHANNEL_DATA_TYPE_STRING
: A string.CHANNEL_DATA_TYPE_BOOL
: A boolean.CHANNEL_DATA_TYPE_INT_32
: A 32bit signed integer.CHANNEL_DATA_TYPE_INT_64
: A 64bit signed integer.CHANNEL_DATA_TYPE_UINT_32
: A 32bit unsigned integer.CHANNEL_DATA_TYPE_UINT_64
: A 64bit unsigned integer.CHANNEL_DATA_TYPE_ENUM
:CHANNEL_DATA_TYPE_BIT_FIELD
:
Embedded Configuration
You can also supply the configuration for each column as a JSON encoded object in the CSV file itself. Each column must encode it's configuration object separately as a CSV string. The configuration can be in either the first or second row of the data.
The objects for the time column and data column correspond to the time_column
and data_columns
objects from the CSV configuration.
For example, the time column object will look like this:
And each data column object will look like this:
Import Data from CSV files using sift-stack-py
Getting started with sift-stack-py
Be sure to visit the Python Quickstart section of the documentation to see how to get started with the Sift Python client library before continuing.
In this example, our goal will be to upload a CSV called sample_asset.csv
which will have
the following format.
Using sift-stack-py
, we can upload the CSV as is like so:
For more comprehensive examples you can visit the Sift public repository.