Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi ,
I am trying to read data from CSV using ReadCSVFile from CSV Parser Extension snippets.
I am getting below error while am trying to read data.
Error executing service importUserNames. Message :: Unable To Open [TestName.csv] in [SystemRepository] : Index: 2, Size: 2 car- See Script Error Log for more details.
Can someone help me in resolving this issues.
Here is service code and attaching sample CSV am trying to upload.
var params = {
path: fileName /* STRING */,
columnMappings: 'Name;FullName;Password' /* STRING */,
hasHeader: true /* BOOLEAN */,
fileRepository: "SystemRepository" /* THINGNAME */,
fieldDelimiter: "," /* STRING */,
dataShape: "ImportUsers" /* DATASHAPENAME */
};
// result: INFOTABLE
var result = Resources["CSVParserFunctions"].ReadCSVFile(params);
for(var i=0;i<result.length;i++)
{
var params = {
password: result[i].Password /* STRING */,
name: result[i].Name /* STRING */,
description: result[i].FullName /* STRING */
};
// no return
Resources["EntityServices"].CreateUser(params);
};
Solved! Go to Solution.
Can you open your csv file in a text editor and check that it is actually using a comma as delimiter.
This sample code works for me but I did get the same error when my csv was not formatted as expected.
If you still have issue, could you confirm the version of ThingWorx you are using and can you upload the actual csv file (not a screenshot of it)
Hope this helps
Christophe
Can you open your csv file in a text editor and check that it is actually using a comma as delimiter.
This sample code works for me but I did get the same error when my csv was not formatted as expected.
If you still have issue, could you confirm the version of ThingWorx you are using and can you upload the actual csv file (not a screenshot of it)
Hope this helps
Christophe
Hi Christophe,
Yes, My CSV file was corrupted and it worked with new CSV file.
I am pleased to hear that the issue is fixed on your side.
In that case would it be possible for you to accept one of the answer as solution so that others can find more easily the solution to similar issue ?
Thank you
Kind regards
Christophe