cdf data upload command to upload data files from your local machine to Cognite Data Fusion (CDF). The command processes structured directories containing data files and their corresponding manifest files. The manifest files define how the data should be uploaded.
Prerequisites
Before uploading data, ensure you have:- Installed and configured the Cognite Toolkit.
- Authenticated with CDF using appropriate credentials.
- Prepared your data files in the required directory structure.
- Created manifest files for each data file you want to upload.
Directory structure
The upload command requires a directory containing your data files. Organize the directory using this structure:- Searches for all YAML files with the
.Manifest.yamlsuffix. - For each manifest file, locates the data file with the same prefix.
- If
--deploy-resources, deploys all resources in the resource directory. - Uploads the data files for each manifest.
--deploy-resources flag when running the upload command, the Cognite Toolkit creates these resources before uploading the data.
When you download a resource, the Cognite Toolkit automatically places the downloaded files in your selected directory with the specified format.
Upload data
1
Confirm your directory layout
Use the layout in Directory structure: manifest files with the
.Manifest.yaml suffix, data files whose names share the same prefix as the manifest, and optional resources/ when definitions must exist before upload (for example RAW table metadata).2
Run the upload command
From a terminal, run Replace
cdf data upload dir with the path to the directory that contains your manifests and data files:path/to/input_dir with your directory. --cdf-project must match the project in your credentials. If you omit the flag, the command prompts you to type the project name. Pass --overwrite to replace existing data when the data type supports it. For flags and arguments, run cdf data upload dir --help.3
Deploy related resources (optional)
If you use a
resources/ folder, pass --deploy-resources so the Cognite Toolkit creates or updates those resources before uploading the data files:4
Verify the upload
Confirm that the command finishes without errors. In Cognite Data Fusion, open the relevant experience for your data type (for example RAW explorer for rows in CDF RAW, or Search for assets and time series) and confirm that the data appears as expected.
Assets
Kind: Assets Supported data file formats: .ndjson, .csv, .parquet API endpoint: /assets You can upload assets from a record (.ndjson) or tabular (.csv, .parquet) format.
The manifest file for assets can specify a data set or a hierarchy:
myDataSet.Manifest.yaml
myHierarchy.Manifest.yaml
myHierarchy-part-0001.Assets.ndjson
myDataSet.Assets.csv
Canvas
Kind: IndustrialCanvas Supported data file format: .ndjson API endpoint: No public API You can upload canvases using a record (.ndjson) format. The manifest file specifies the external IDs of the canvases to upload:
myCanvases.Manifest.yaml
myCanvases-part-0001.IndustrialCanvas.ndjson
You usually download canvases with the
cdf data download canvas command, for example to copy canvases between CDF projects.Charts
Kind: Charts Supported data file format: .ndjson API endpoint: No public API You can upload charts using a record (.ndjson) format. The manifest file specifies the external IDs of the charts to upload:
myCharts.Manifest.yaml
myCharts-part-0001.Charts.ndjson
Charts are typically downloaded using the
cdf data download charts command.Datapoints
Kind: Datapoints Supported data file formats: .csv, .parquet API endpoint: /timeseries/data You can upload datapoints using tabular (.csv, .parquet) formats. The manifest type determines the layout of the data file:
Use
datapointsInstanceSpace for state time series. To upload status codes, use one of the row-per-datapoint (long) formats.
From Cognite Toolkit v0.9.112, for all types, the Cognite Toolkit:
- Reads timestamps without a time zone as UTC.
- Skips values it can’t convert, and logs the number of skipped values.
- Skips datapoints for time series that don’t exist in CDF instead of failing the whole upload.
Datapoints file (wide format)
Withtype: datapointsFile, each column holds the values of one time series. The manifest file specifies the mapping
between the columns in the data file and the time series identifiers. The identifiers can be
either internal IDs, external IDs, instance IDs, or a mix of these. In addition, you need to specify the
column containing the timestamps:
myDatapoints.Manifest.yaml
myDatapoints.Datapoints.csv
Datapoints from a data set (long format)
Withtype: datapointsDataSet, each row holds one datapoint, and the externalId column identifies the time series. Use this format to upload
status codes, for example to mark a datapoint as bad. The manifest file specifies the data type of the time series:
myDatapoints.Manifest.yaml
cdf data download datapoints downloads. On upload, the Cognite Toolkit writes to the time series in the externalId column, even if that time series isn’t in the data set.
The data file must have exactly the columns externalId, timestamp, and value, and optionally statusCode. The upload fails if the file has other columns:
myDatapoints.Datapoints.csv
Datapoints from an instance space (long format)
Requires Cognite Toolkit v0.9.112 or later and alpha flagextend-download enabled
With type: datapointsInstanceSpace, each row holds one datapoint for a CogniteTimeSeries, and the space and externalId columns identify the time series.
This is the only format that uploads state time series.
myDatapoints.Manifest.yaml
cdf data download datapoints downloads. On upload, the Cognite Toolkit writes to the time series in the space and externalId columns of each row, even if that space is a different instance space.
The required columns depend on the data type:
The data file must have exactly the required columns, and optionally
statusCode. The upload fails if the file has other columns. For state time series, each row needs a value in numericValue, stringValue, or both, unless the status code is Bad. numericValue must be a 32-bit integer:
myStateDatapoints.Datapoints.csv
extend-download alpha flag isn’t enabled, the Cognite Toolkit skips manifests with type: datapointsInstanceSpace and shows a warning.
Status codes
In thedatapointsDataSet and datapointsInstanceSpace formats, the optional statusCode column holds the status code of each datapoint as a decimal number, for example 2147483648 for Bad. Leave the cell empty for datapoints with status Good.
A datapoint can be without a value only if its status code is Bad. The Cognite Toolkit skips rows that have neither a value nor a status code, and logs the number of skipped rows.
Create long-format files with the download command
You usually createdatapointsDataSet and datapointsInstanceSpace files with the cdf data download datapoints command, which writes the data files and the manifest. To download from an instance space, use --instance-space and --data-type, for example --data-type state --instance-space my_instance_space. See Download data using the Data plugin.
A downloaded manifest can include start and end, which limit the time range of the download. The upload ignores them.
Events
Kind: Events Supported data file formats: .ndjson, .csv, .parquet API endpoint: /events You can upload events using record (.ndjson) and tabular (.csv) formats. The manifest file specifies the target data set or the root asset for the event hierarchy:
myDataSet.Manifest.yaml
myHierarchy.Manifest.yaml
myEvents-part-0001.Events.ndjson
myEvents.Events.csv
Files
Kind: FileContent Supported data file format: Any format for the file content itself API endpoint: /filesFileMetadata with content
Requires Cognite Toolkit v0.8.10 or later. Versions before 0.9 also require theextend-upload alpha flag.
Supported metadata file format: .ndjson, .csv, .parquet
You can upload FileMetadata (asset-centric files) in either record (.ndjson) or tabular (.csv, .parquet) formats.
If your Cognite Toolkit version is older than 0.8.10, use the legacy manifest format with
fileMetadataTemplate instead.Template manifest file
myFileMetadata.Manifest.yaml
fileDirectory:
$FILENAME with the actual
file name. For example, file1.txt will be uploaded with:
file1.FileMetadata.yaml
FileMetadata IDs manifest file
You can also upload files using a manifest file that instructs the Cognite Toolkit to simply read the files from CSV, Parquet, or NDJSON files.myFileMetadata.Manifest.yaml
myFileMetadata.Manifest.yaml, you can have myFileMetadata.csv with the following content:
myFileMetadata.csv
$FILEPATH column are relative to the location of the manifest file.
Combined with this layout, the directory is expected to look like this:
Cognite File with content
Requires Cognite Toolkit v0.8.34 or later. Versions before 0.9 also require theextend-upload alpha flag.
Supported metadata file format: .ndjson, .csv, .parquet
You can upload Cognite Files (instances in the data model) in either record (.ndjson) or tabular (.csv, .parquet) formats.
If your Cognite Toolkit version is older than 0.8.34, use the legacy manifest format with
fileDataModelingTemplate to upload Cognite File instances with content.Template manifest file
myCogniteFile.Manifest.yaml
fileDirectory:
$FILENAME with the actual
file name. For example, file1.txt will be uploaded with:
file1.CogniteFile.yaml
Cognite File IDs manifest file
You can also upload files using a manifest file that instructs the Cognite Toolkit to simply read the files from CSV, Parquet, or NDJSON files.myCogniteFile.Manifest.yaml
myCogniteFile.Manifest.yaml, you can have myCogniteFile.csv with the following content:
myCogniteFile.csv
$FILEPATH column are relative to the location of the manifest file. Combined with this layout, the directory is expected to look like this:
Legacy format for manifest file with content
Use these manifest formats if you run a Cognite Toolkit version before 0.9 that does not support theFileMetadataContent or CogniteFileContent kinds documented above.
Requires alpha flag extend-upload to be enabled
Supported metadata file format: .ndjson
Template for manifest file
You can upload files with content using a template format for the manifest file. Classic template format:myFileMetadata.Manifest.yaml
myFileMetadata.Manifest.yaml
fileDirectory:
$FILENAME with the actual file name.
Records
Kind: Records Supported data file format: .ndjson From Cognite Toolkit version 0.9, upload records with a manifest oftype: recordContainer. The manifest names the stream and the record container.
myRecords.Manifest.yaml
Instances
Kind: Instances Supported data file formats: .ndjson, .csv, .parquet API endpoint: /models/instances You can upload instances using the record (.ndjson) format. The manifest file specifies the instance space for the instances:
myInstances.Manifest.yaml
myInstances-part-0001.Instances.ndjson
myInstances.Instances.csv
Guided upload from a CSV or Parquet file
Requires theextend-upload alpha flag.
Use cdf data upload instances to upload a CSV or Parquet file as instances to a view without writing the manifest file yourself:
- Prompts you to select the view to upload the instances to, and whether the file contains nodes or edges.
- Checks that the file has the required columns. Nodes require
spaceandexternalId. Edges also requiretype.space,type.externalId,startNode.space,startNode.externalId,endNode.space, andendNode.externalId. - Shows how each column maps to an instance field or a view property. If a column isn’t a property in the view, the command warns you that the upload fails unless you rename or remove the column, and asks whether to create the manifest anyway.
- Writes the manifest file next to the data file, named
<file name without extension>.Manifest.yaml. If the manifest file already exists, the command asks before it overwrites it. - Asks whether to upload the file now, do a dry run, or only keep the manifest file. To upload the file later, run
cdf data upload diron the folder with the file.
my_assets.csv uploaded as nodes to the CogniteAsset view, the command creates this manifest:
my_assets.Manifest.yaml
cdf data upload dir uses a manifest file for every data file whose name starts with the same prefix. If other files in the folder share the prefix, the command warns you.Raw
Kind: RawRows Supported data file formats: .ndjson, .csv, .parquet API endpoint: /raw/dbs//tables//rows You can upload rows to CDF RAW using the record (.ndjson) and tabular (.csv, .parquet) formats. The manifest file specifies the
database and table the data should be uploaded to. In addition, for table formats, you can specify the column that should be used as the unique row identifier. If not specified, CDF automatically generates row IDs.
myRawData.Manifest.yaml
myRawData-part-0001.RawRows.ndjson
myRawData.RawRows.csv
Use case: Upload metadata to CDF RAW
The Cognite Toolkit manages resource configurations, which are typically metadata rather than data. For example, a sensor’s name, location, type, and attached asset are metadata, while the sensor readings are data. Metadata is often available from a source system. You can use an extraction pipeline to extract and ingest the metadata into CDF. If the metadata isn’t available from a source system, you can store it in CSV files and version-control the files in a Git repository. Use the data plugin to upload the metadata to CDF RAW tables, then use transformations to write the metadata to the correct destination resources. This approach lets you track metadata changes and use the Git repository as the single source of truth. In a CI/CD pipeline, add an upload step after you build and deploy the configurations:1
Build
Build the configurations with
cdf build.2
Deploy configuration resources
Deploy the resources with
cdf deploy.3
Upload metadata to CDF RAW
Upload the metadata:Pass
--cdf-project so the command doesn’t prompt for the project name and stop the pipeline.path/to/raw_metadata directory contains the manifest file and the data file for each RAW table. Set key in each manifest file. Without a key column, CDF generates new row IDs on every upload, and each pipeline run adds another copy of the rows.
If the RAW databases and tables are defined in a resources/ folder next to the data files, you can skip the separate cdf deploy step for them and pass --deploy-resources to cdf data upload dir instead. For more information, see Upload data.
cdf deploy and cdf data upload behave differently:
cdf deploycompares the local resource definitions to the resources in CDF. It creates new resources, updates changed resources, and leaves unchanged resources as they are.cdf data uploadwrites all rows in the data files on every run. Rows with a key that already exists in the table are replaced. Rows in the table that aren’t in the data files remain. The command is built to handle large amounts of data efficiently.
Time series
Kind: TimeSeries Supported data file formats: .ndjson, .csv, .parquet API endpoint: /timeseries You can upload time series definitions using the record (.ndjson) and tabular (.csv) formats. The manifest file specifies the target data set
or the root asset for the hierarchy the time series is connected to:
myDataSet.Manifest.yaml
myHierarchy.Manifest.yaml
myTimeSeries-part-0001.TimeSeries.ndjson
myTimeSeries.TimeSeries.csv