Skip to main content
1-Visitor
May 22, 2019
Solved

Unable to read csv file in ReadCSVFile method

  • May 22, 2019
  • 1 reply
  • 2161 views

I am trying to create a java code to read a csv file. The file is located in the systemrepository.

I am using the below code, but unable to get the result

 

DataShapeDefinition dsd = new DataShapeDefinition();
dsd.addFieldDefinition(new FieldDefinition("Field1", BaseTypes.STRING));
dsd.addFieldDefinition(new FieldDefinition("Field2", BaseTypes.STRING));
dsd.addFieldDefinition(new FieldDefinition("Field3", BaseTypes.STRING));

//mything.get
CSVParser csvParser = new CSVParser();
InfoTable csvInfotable = new InfoTable();
csvInfotable.setDataShape(dsd);
_logger.warn("InfotableCreated");
try {
csvInfotable = csvParser.ReadCSVFile("SystemRepository", "/new 1.csv", "TestDataShape",
hasHeader, columnMappings, null, null, dateFormat, ",", "\"");
_logger.warn("InfotableCreated after readCSV function");
//code to identify the memory usage

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

The error i am getting is: com.thingworx.common.exceptions.InvalidRequestException: Unable To Open [/new1.csv] in [SystemRepository] : null

attached is the sample csv file

Any help in this matter would be appreciated.

1 reply

abarki5-Regular MemberAnswer
5-Regular Member
May 24, 2019