cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

unable to open csv file using csvparser - ReadCSVFile from system repository

polasaikrishna
6-Contributor

unable to open csv file using csvparser - ReadCSVFile from system repository

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);

};

 

 

ACCEPTED SOLUTION

Accepted Solutions

@polasaikrishna 

 

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

 

View solution in original post

3 REPLIES 3

@polasaikrishna 

 

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.

 

@polasaikrishna 

 

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

 

Announcements


Top Tags