Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
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
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