Skip to main content
Solved

Any ideas how to parse csv data in single attribute?

  • September 25, 2018
  • 6 replies
  • 182 views

johnglick
Contributor
Forum|alt.badge.img+7

I have csv data in a single attribute like this (field names are first line).

Grower,Date,SampleNum,P,K,C

1000,05/01/2018,350,275,1500

how can I parse this into feature(s) with the correct collums using fme?

Best answer by david_r

I believe this answer should cover your case:

https://knowledge.safe.com/questions/78520/parse-csv-data-stored-in-database-table.html

The first feature will contain the attribute names, the following features will contain the values. If necessary you can use the Sampler to get rid of the first feature.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • Contributor
  • September 25, 2018

In the CSV reader you can:

- Check the box to have field names in the first row

- Determine the , to be the separator

FME will then read all rows and use the first row for attribute naming.


johnglick
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • September 25, 2018

In the CSV reader you can:

- Check the box to have field names in the first row

- Determine the , to be the separator

FME will then read all rows and use the first row for attribute naming.

Sorry, I wasn't very clear, my data originates in an attribute downloaded from a webservice, not an actual csv file.

 

 


erik_jan
Contributor
Forum|alt.badge.img+26
  • Contributor
  • September 25, 2018
Sorry, I wasn't very clear, my data originates in an attribute downloaded from a webservice, not an actual csv file.

 

 

You can still do the same.

 

But use the AttributeFileWriter to write to a CSV file, followed by a FeatureReader to read as CSV.

 

 


takashi
Celebrity
  • September 26, 2018
Sorry, I wasn't very clear, my data originates in an attribute downloaded from a webservice, not an actual csv file.

 

 

Alternatively, you can use the HTTPCaller to download and save the CSV data into a file. You can then re-read the file with the FeatureReader (Format: CSV).

 

 


johnglick
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • September 26, 2018

In the CSV reader you can:

- Check the box to have field names in the first row

- Determine the , to be the separator

FME will then read all rows and use the first row for attribute naming.

I wasn't able to get the feature writer to feature reader flow working, messed around with it for a bit but it still just returns my csv data under one attribute. Seems like I'm missing something simple. The data I'm working with is embedded in an xml response from a SOAP api. I've attached the entire xml response so you can see what I'm referring to. download-resuts.xml. I'm using the xml fragmenter to extract the data from get_sampleresultsResults attribute.

 

 


david_r
Celebrity
  • Best Answer
  • September 26, 2018

I believe this answer should cover your case:

https://knowledge.safe.com/questions/78520/parse-csv-data-stored-in-database-table.html

The first feature will contain the attribute names, the following features will contain the values. If necessary you can use the Sampler to get rid of the first feature.