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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

ReadCSVFile Issue

khayes1
15-Moonstone

ReadCSVFile Issue

Hi, having an issue reading a csv file from a repository on Thingworx using the CSV Parser function ReadCSVFile(). The file was written to the repository using the WriteCSVFile() passing in an infotable.

It returns an empty table and I can see the error message:

JavaException: com.thingworx.common.exceptions.InvalidRequestException: Unable To Open [/Notification Config/CIJNotificationConfigTable.csv] in [XXXX.FileRepository] : Unable To Convert From java.lang.String to INTEGER #28

 

After investigating the issue appears to be that the order that the columns are written to the csv file are different  to the order than defined in the infotable datashape. So when I try and read it back using the datashape it fails.

 

If anyone has any idea why it might write it out in the wrong order that would be helpful. Failing that, can I use the 'columnMappings' parameter to sort it?

If the answer is yes, does anyone know the format that the parameter should take and whether or not i need to provide a mapping for every column, or can just do the errant ones.

 

Thanks in advance

K

ACCEPTED SOLUTION

Accepted Solutions
khayes1
15-Moonstone
(To:emscur)

Hi, 

thanks for the reply. I think I have just got to the root of the problem. I exported the datashape being used to an XML file. When I viewed the file in an editor I could see that there were duplicate 'ordinal' values for some of the fields. Not sure how this happened, but after manually changing them to be in the correct order (matching the datashape as viewed in the composer) and importing the file back, everything works correctly. 

 

khayes1_0-1599155128130.png

 

 

I suspect the WriteCSVFile must be using the 'ordinal' value to decide how to write the csv.

View solution in original post

3 REPLIES 3
emscur
13-Aquamarine
(To:khayes1)

Hello @khayes1,

 

The error message seems to be tracing back to divergent variable types.Try setting all fields of the data shape from Integer to String, this should resolve the issue.

Regards,

Emmanuel

khayes1
15-Moonstone
(To:emscur)

Hi, 

thanks for the reply. I think I have just got to the root of the problem. I exported the datashape being used to an XML file. When I viewed the file in an editor I could see that there were duplicate 'ordinal' values for some of the fields. Not sure how this happened, but after manually changing them to be in the correct order (matching the datashape as viewed in the composer) and importing the file back, everything works correctly. 

 

khayes1_0-1599155128130.png

 

 

I suspect the WriteCSVFile must be using the 'ordinal' value to decide how to write the csv.

emscur
13-Aquamarine
(To:khayes1)

Hello @khayes1,

 

Thank for your providing this information. I suspect this is exactly what is happening when writing the CSV file, I am glad you were able to figure it out and thanks for sharing the solution to this thread!

Regards,

Emmanuel

Announcements


Top Tags