Skip to content

Adding a column mapping

The first time you push data to a new project, you have to define:

The file BankLoanData-EN.csv is a CSV file which contains several columns that need to be mapped using a column mapping.

BankLoanData_EN.png

The file structure and column mapping must be defined as a JSON:

{
"fileStructure":{
"charset":"UTF-8",
"delimiter":";",
"quoteChar":"\"",
"eolChar":"\\n",
"header":true,
"commentChar":"#",
"fileType":"csv"
},
"columnMapping":{
"caseIdMapping":{
"columnIndex":0
},
"activityMapping":{
"columnIndex":3
},
"timeMappings":[
{
"columnIndex":1,
"format":"yyyy/MM/dd HH:mm/ss.SSS"
},
{
"columnIndex":2,
"format":"yyyy/MM/dd HH:mm/ss.SSS"
}
],
"dimensionsMappings":[
{
"name":"Role",
"columnIndex":4,
"isCaseScope":false,
"caseAggregation":"DISTINCT"
}
]
}
}

To add a column mapping, the syntax is different depending on if you are using a Linux or Windows terminal. The command needs to be formatted differently depending on the system as Windows uses different syntax for some commands. The single quotes need to be replaced and so a backslash must be added in front of every double quote.

For Linux:

curl -X POST "<Your API URL>/pub/project/<Your Project ID>/column-mapping" -H "accept: /" -H "Authorization: Bearer <Your generated Token>" -H "Content-Type: application/json" -d '{"fileStructure":{"charset":"UTF-8","delimiter":";","quoteChar":"\"","escapeChar":"\\","eolChar":"\\n","header":true,"commentChar":"#","fileType":"csv"},"columnMapping":{"caseIdMapping":{"columnIndex":0},"activityMapping":{"columnIndex":3},"timeMappings":[{"columnIndex":1,"format":"yyyy/MM/dd HH:mm:ss.SSS"},{"columnIndex":2,"format":"yyyy/MM/dd HH:mm:ss.SSS"}],"dimensionsMappings":[{"name":"Role","columnIndex":4,"isCaseScope":false,"caseAggregation":"DISTINCT"}]}}' -v

If the command works, it will return a 204 HTTP code.

For Windows:

curl -X POST "<Your API URL>/pub/project/<Your Project ID>/column-mapping" -H "accept: /" -H "Authorization: Bearer <Your generated Token>" -H "Content-Type: application/json" -d "{\"fileStructure\":{\"charset\":\"UTF-8\",\"delimiter\":\";\",\"quoteChar\":\"\\\"\",\"escapeChar\":\"\\\\\",\"eolChar\":\"\\n\",\"header\":true,\"commentChar\":\"#\",\"fileType\":\"csv\"},\"columnMapping\":{\"caseIdMapping\":{\"columnIndex\":0},\"activityMapping\":{\"columnIndex\":3},\"timeMappings\":[{\"columnIndex\":1,\"format\":\"yyyy/MM/dd HH:mm:ss.SSS\"},{\"columnIndex\":2,\"format\":\"yyyy/MM/dd HH:mm:ss.SSS\"}],\"dimensionsMappings\":[{\"name\":\"Role\",\"columnIndex\":4,\"isCaseScope\":false,\"caseAggregation\":\"DISTINCT\"}]}}" -v

If the command works, it will also return a 204 HTTP code.

If the code is 500, it means that there is already a column mapping.

Checking if the column mapping exists

After adding a column mapping, we can check if it exists, to make sure it has been added.

curl -X GET "<Your API URL>/pub/project/<Your Project ID>/column-mapping-exists" -H "accept: /" -H "Authorization: Bearer <Your generated Token>" -H "Content-Type: application/json"

If the request is successful and the column mapping exists, the command will return the following line:

{"exists":true}