Import CSV


You can mimic the import functionality you see in Operator by making your own import process for CSV files.

We'll assume you know how to upload files through the API and that you have access to a TempFile.ID or ClientFile.ID.

Import

CSV Import

Request body
interface IPostBody {
    // Previously uploaded temp file ID or Client File ID.
    // One of these is required.
    "TempFile.ID": string;
    // File name used for creating an import record.
    // Eg: 'my-file.csv'.
    // If you specify a Client File ID, this is not needed as the name is already known.
    "TempFile.Name": string;
    "ClientFile.ID": string;

    // Specifies how the rows should be imported.
    // Eg: 'A' for add, 'U' for update, 'R' for replace (delete before importing).
    // You can also use 'U+A' to update or add (our default).
    // Or 'U+A+D' to update or add, then delete any Entities not in the CSV.
    // These are all relative to the specified Entity Type.
    "ImportMode": "A" | "U" | "R" | "U+D" | "U+A" | "U+D+A";
    // Set to true to skip rows that fail to import.
    // If false, the first failure will stop the import.
    "SkipFailedRows"?: boolean;

    // Destination Entity Type.
    "EntityType.ID": string;
    // Array of Nextspace Tag IDs to apply to all imported Entities.
    "AddLayerIDs"?: number[];

    // The character to split the CSV rows by.
    // Eg: ',' for comma.
    "Delimiter": string;
    // Specify the row index where the header is located.
    // Rows after this index are imported.
    // Specify -1 to indicate that there is no header.
    "HeaderIndex": number;

    // Array of column names in the CSV.
    // These are used as the key/names for attributes during data mapping.
    // Eg: if you say the first index is 'Name', then we'll look for the 'Name' attribute in the data mapping.
    // We will assume all first column values are for that attribute.
    "CSVColumns": string[];
    // Data mapping for the CSV columns to the target Entity Type schema.
    "DataMapping": any;
}
Response
interface IResponse {
    "PendingActionID": number;
}
Javascript example

When the Pending Action is marked as completed, here is the result to expect:

interface IResult {
    // Estimate of total rows. Can be inaccurate due to empty rows of ones skipped.
    "TotalRowsEst": number;
    // Last row index processed.
    // If it's set to not skip failed rows, then this can help you determine where the failure occurred.
    // Note that it might not be the exact row index.
    "LastProcessedRow": number;
    // Number of failed to import rows.
    "CountFailed": number;
    // Number of successfully imported rows.
    "CountImported": number;
}