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

CSV Parser Help

SOLVED
Newbie

CSV Parser Help

So, I am running 6.0 and am trying to parse a CSV file.  I have downloaded the CSV Parser Extension and have boiled down the code to the bare minimum and haven't been able to get it to work.

In fact, I have a very simple test and my results are the same as when I use the GetCSVFile Method.  Here below I am using a very simple example and the result is that I only get the very first column and not the second column. I am certain I am doing something wrong but I haven't been able to locate the documentation for the extension.  I have looked through the forum and found links but they are dead links. 

Can someone help with getting the Description column populated?

Thanks in advance

var params = {

  columnMappings: "Tagname; Description;" /* STRING */,

  hasHeader: "false" /* BOOLEAN */,

  longitudeField: undefined /* NUMBER */,

  dateFormat: undefined /* STRING */,

  latitudeField: undefined /* NUMBER */,

  fieldDelimiter: undefined /* STRING */,

  stringDelimiter: undefined /* STRING */,

  content: '"XV101,Valve Input"' /* STRING */,

  dataShape: "PES_Tags" /* DATASHAPENAME */

};

// result: INFOTABLE

var result = Resources["CSVParserFunctions"].ParseCSVFile(params);

1 ACCEPTED SOLUTION

Accepted Solutions

Re: CSV Parser Help

Few things that may cause it:

  • ColumnMappings
    • Remove spaces between columns ( you have a space after the ";" )
    • Remove the last ";"
  • hasHeader
    • change "true" for true
  • FieldDelimiter
    • ","
  • StringDelimiter
    • "\""
  • content
    • I've never parsed a string content, I parse csv files from file repositories
    • But on your case, you are opening and closing a " on your content, you should not, at least for all the row, you can for every String column
    • When you parse CSV files you need a blank line at the end, maybe it's the case with content, then you will need to add at the end \n
  • dataShape, it should exist.

View solution in original post

29 REPLIES 29

Re: CSV Parser Help

Few things that may cause it:

  • ColumnMappings
    • Remove spaces between columns ( you have a space after the ";" )
    • Remove the last ";"
  • hasHeader
    • change "true" for true
  • FieldDelimiter
    • ","
  • StringDelimiter
    • "\""
  • content
    • I've never parsed a string content, I parse csv files from file repositories
    • But on your case, you are opening and closing a " on your content, you should not, at least for all the row, you can for every String column
    • When you parse CSV files you need a blank line at the end, maybe it's the case with content, then you will need to add at the end \n
  • dataShape, it should exist.

View solution in original post

Re: CSV Parser Help

Hi Jeff,

Here is an example per the test data you provided and it works on my Thingworx 7.0.0-b479:

var params = {

    columnMappings: "Tagname;Description" /* STRING */,

    hasHeader: "false" /* BOOLEAN */,

    longitudeField: undefined /* NUMBER */,

    dateFormat: undefined /* STRING */,

    latitudeField: undefined /* NUMBER */,

    fieldDelimiter: "," /* STRING */,

    stringDelimiter: "\"" /* STRING */,

    content: "XV101,Valve Input\n" /* STRING */,

    dataShape: "PES_Tags" /* DATASHAPENAME */

};

// result: INFOTABLE

var result = Resources["CSVParserFunctions"].ParseCSVFile(params);

Hope this helps,

Thanks,

Br,

Anna

Re: CSV Parser Help

Thanks both of you!!!! My issue was the space between the columnMappings... I appreciate it.

Highlighted

Re: CSV Parser Help

Hi.

If i am having a column which data type is date time means, how to parse in thingworx? 

Re: CSV Parser Help

Hi,

 

I am new to thingworx, can you help me on CSV Parser plugin, I dont know how to use this and how should i implement it.

 

Regards
Vikas

Re: CSV Parser Help

Hi,

I used below script to parse CSV Data.

 

var params = {
path: "/"+ file /* STRING */,
columnMappings: undefined /* STRING */,
hasHeader: true /* BOOLEAN */,
longitudeField: undefined /* NUMBER */,
dateFormat: undefined /* STRING */,
fileRepository: "SystemRepository" /* THINGNAME */,
latitudeField: undefined /* NUMBER */,
fieldDelimiter: undefined /* STRING */,
stringDelimiter: undefined /* STRING */,
dataShape: "parseCSV" /* DATASHAPENAME */
};
var result = Resources["Parsley"].ParseCSV(params);   //result: INFOTABLE

file - CSV file name(eg. "data.csv")
parseCSV - Datashape Name which have all field names with "STRING" basetype. 

 

Thanks & Regards,

Sathishkumar C.

Tags (1)

Re: CSV Parser Help

Hi Satish,

 

I understood the script, I dont know the way from where i should start and upload csv file to run this script?

can you plz tell me?

Re: CSV Parser Help

Use Upload widget with Mashup.

Re: CSV Parser Help

Thanks Satish for prompt reply.

 

so, i have to follow following steps?

 

1) create datashapre

2) upload widget

3) create service with provided code

 

If Am i right? there is otherway to import csv directly without creating Mashup.

 

Regards

Vikas

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________