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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

adding data shapes to mashup for reading CSV file.

svisveswaraiya
17-Peridot

adding data shapes to mashup for reading CSV file.

Hi,

How can we read a csv file and display it in a grid?

Using a button named as Upload, I need to upload a excel file and that file data should display in a grid.

How is it possible?

 

Please provide some guidance.

 

Thanks,

V Shalini. 

1 REPLY 1
jamesm1
5-Regular Member
(To:svisveswaraiya)

You will need the Parsley extension from the Marketplace.

 

Create a new FileRepository Thing. Create a service called something like ParseCSV with the input parameter of path, of type String. The output should be an InfoTable with no DataShape. 

It should look something like this:

var params = {
	path: path /* STRING */,
	hasHeader: true /* BOOLEAN */,
	dateFormat: undefined /* STRING -- Joda date format if you want it to parse datetime fields in the csv. Otherwise it will convert them to Strings */,
	fileRepository: me.name /* THINGNAME */
};

var result = Resources["Parsley"].ParseCSV(params);

Now, in your mashup, bring that service into the mashup using the Add Data button. Add two widgets: 

  • File Upload widget
  • Grid

 

On the FileUpload widget, set the RepositoryName property to the one we created above and uncheck display repository. Optional: bind the username to the path (you might need to use an Expression widget to add a / ) -- this will make the files unique to that user so the same file names don't overwrite. Bind the FullPath attribute to the path parameter in the ParseCSV server and bind the UploadComplete event to trigger the service.

 

Add a grid widget and bind the results from ParseCSV to the grid. make sure to select the ShowAllColumns attribute.

 

Save the mashup and you should be good to go.

 

Note that this will only work for CSV file types, not xlsx.

 

 

Top Tags