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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to get date column from CSV file when Parsley extension using

CR_10422526
4-Participant

How to get date column from CSV file when Parsley extension using

Hi,

Please help on following ,

 

I want to get date field from CSV file.  If I apply dataShape (Date column as Datetime). will getting error (tried many ways, still didn't get answer). 

 

let params = {
path: "/PhysicalTestMachineData.csv" /* STRING {"defaultValue":"/"} */,
columnMappings: undefined /* STRING */,
hasHeader: true /* BOOLEAN {"defaultValue":false} */,
longitudeField: undefined /* NUMBER */,
dateFormat: parseDate(Date, "DD/MM/YYYY") /* STRING */,
fileRepository: "SystemRepository" /* THINGNAME */,
latitudeField: undefined /* NUMBER */,
fieldDelimiter: "," /* STRING {"defaultValue":","} */,
stringDelimiter: undefined /* STRING {"defaultValue":"\""} */,
customFieldNames: undefined /* STRING */,
dataShape: "Physical_E1" /* DATASHAPENAME */
};

// result: INFOTABLE
let result = Resources["Parsley"].ParseCSV(params);

 

.....>>>

 Error executing service GetPhysicalTest_CSV_1. Message :: Invalid format: "org.mozilla.javascript.IdFunctio..." - See Script Error Log for more details.

 

Thank you

2 REPLIES 2

@CR_10422526 ,

 

I know this solution isn't ideal, but you can add an extra text field to your datashape to accept the string value of the date, and then use the:

 

var newDate = new Date(dateString);

 

to get it to the format you need for your DateTime column.

 

Hope that helps

- Nick

You didn't provide sample data or the datashape, plus Parsley is not a PTC-supported extension, so you might get better advice asking the developer. I've seen him around here @jamesm1 

The images at https://github.com/jmccuen/parsley seem to be broken as well which leaves us with little information, but from what I can see, wouldn't you just use the plain date format in the parameter?, e.g.

dateFormat: "DD/MM/YYYY",

 

EDIT: What's probably also to know is that you have to use joda time format for your format string. See https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html

Try dd/MM/yyyy

 

 

 

Announcements


Top Tags