Importing CSV files
The import commands for CSV files must have the mandatory operation fields and identifier requirements as the import commands. The difference is that the JSON template contains placeholders for the data that must be retrieved from the CSV file:
${n}, where n represents the number of the table column.
You can use a combination of placeholders and hard-coded values in the JSON template.
JSON template structure
[{
"resourceType": "Community"
"identifier": {
"id": "${n}" //placeholder, where n = 1, 2, 3...)
},
"parent": {
"id": "9f01ccd6-3329-49ef-af9a-3e1c9826f731"
},
},
{
"resourceType": "Domain"
"identifier": {
"id": "${n}"
},
"name": "${n}",
"description": "${n}",
"community": {
"name": "${n}"
},
"type": {
"name": "${n}"
},
},
{
"resourceType": "Asset"
"identifier": {
"name": "${n}",
"domain": {
"name": "${n}",
"community": {
"name": "${n}"
}
},
"relations": {
"relationTypeId:TARGET": [ //for example "9f01ccd6-3329-49ef-af9a-3e1c9826f737:TARGET"
{
"name": "${n}",
"domain": {
"name": "${n}",
"community": {
"name": "${n}"
}
}
}
],
"relationTypeId2": [ //the direction is not needed if it can be implicitly resolved
{
"name": "${n}",
"domain": {
"name": "${n}",
"community": {
"name": "${n}"
}
}
}
]
},
"attributes": {
"attributeTypeId": [
{
"value": "${n}"
}
],
"attributeTypeId2": [
{
"values": ["${n}"] //a multivalue attribute
}
]
}
},
}]CSV parameters
separator
The delimiter character used to separate entries.
;
quote
The delimiter character used for quoted entries.
"
escape
The delimiter character used to escape separator or quote character.
\
strictQuotes
Whether the characters outside quotes should be ignored.
false
ignoreLeadingWhitespace
Whether whitespace characters before quotes should be ignored.
false
headerRow
Whether the first row of the imported CSV file is the header.
false
Multivalue separator and quote characters
Use the multivalue separator and quote characters when you import multiple values from the same column or the same line of your CSV file.
You can import multiple values from the same column, in an array, indicated by a placeholder enclosed in square brackets in your JSON template:
["${n}"]
If you use the default API request field separator (;), the multivalue separator is ,. Otherwise, the multivalue separator is ;.
For the default API request field separator parameter, the third column in the following CSV example contains two values: C and D.
If you use the default API request quote ("), the multivalue quote is |. Otherwise, the multivalue quote is ".
For the default values for the API request quote parameter, the third column in the following CSV example contains one value: C,D.
You can import multiple resources from the same row, in an array, indicated by the import command enclosed in square brackets:
For the default values for the API request separator parameter, the following combination of CSV and import template upserts two assets: A and B.
The escape character
You can use an escape character to have the Import API treat the following special characters as normal characters when they are part of the values you are importing:
Separator characters
Quote characters
Escape characters
The default escape character is \.
For single value columns and rows, use one escape character before the special character you want to escape:
C\;D
Default separator character: ;
C;D
\"CD\"
Default quote character: "
"CD"
C\\D
Default escape character: \
C\D
For multivalue columns and rows, use two escape characters before the special character you want to escape:
C\\,D
Default multivalue separator character: ,
C,D
`\
CD\
`
C\\\D
Default escape character: \
C\D
Relation and Tag columns
To provide backward compatibility with version 1 of the Import API, version 2 processes Relation and Tag columns as a single value column. Though these columns are still within an array [] in the template, they are not parsed to extract multiple values. If you had escaped or quoted special characters such as the multivalue quote or multivalue separator in v2 so far, you should no longer do so. For the rows to be parsed correctly you must still escape the special characters in a CSV file such as the default escape character, which is the backslash, the default quote, which is the double quote or the default separator, which is the comma. This is valid only for importing assets. You can still import multivalues in a relation column when importing complex relations.
Column numbers x, y, z,and n are all considered as single value columns.
Last updated
Was this helpful?