Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
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
Solved! Go to Solution.
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.
I suspect the WriteCSVFile must be using the 'ordinal' value to decide how to write the csv.
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
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.
I suspect the WriteCSVFile must be using the 'ordinal' value to decide how to write the csv.
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