Hello,
So I found a solution to this:
- Download Custom extension for parsing CSV file from: parsley/parsley_no_poi.zip at master · jmccuen/parsley · GitHub
- Import the Extenstion in to the thingworx
- User below code to convert the CSV data to InfoTable
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "Datashape"
});
FileName = "Type1.csv";
let params = {
path: "/CSV/"+FileName /* STRING {"defaultValue":"/"} */,
hasHeader: false /* BOOLEAN {"defaultValue":false} */,
fileRepository: "Repository" /* THINGNAME */,
fieldDelimiter: ";" /* STRING {"defaultValue":","} */,
};
let data = Resources["Parsley"].ParseCSV(params);
for(let x = 1; x < data.length; x++)
{
let row = data.rows[1].Value1;
rowSplit= row.split(",");
if(!rowSplit[0]) rowSplit[0] = "-";
if(!rowSplit[1]) rowSplit[1] = "-";
if(!rowSplit[2]) rowSplit[2] = "-";
if(!rowSplit[3]) rowSplit[3] = "-";
if(!rowSplit[4]) rowSplit[4] = "-";
let newEntry = {
field1: rowSplit[0], // STRING
field2: rowSplit[1], // STRING
field3: rowSplit[2], // STRING
field4: rowSplit[3], // STRING
field5: rowSplit[4] // STRING
};
result.AddRow(newEntry);
}
The resulting Output be an InfoTable
Thanks,