Skip to main content
Archived

CSV flattener

Related products:FME Form

I wondered why there is no CSV flattener, like JSON or XML flatteners. I had to process CSV in HTTPCaller's response ('_response_body').

So I made my own with Python caller (which is not utf compatible).

import csv, StringIO import fme import fmeobjects # Template Function interface: def processFeature(feature):     pass # Template Class Interface: class FeatureProcessor(object):     def __init__(self):         pass     def input(self,feature):         stringinput = feature.getAttribute('_response_body').encode("ascii","ignore")         reader = csv.DictReader(StringIO.StringIO(stringinput))         for line in reader:             for field in reader.fieldnames:                 feature.setAttribute(field, line[field])             self.pyoutput(feature)     def close(self):         pass

This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

4 replies

david_r
Evangelist
  • August 9, 2016

Did you try using a FeatureReader set to CSV and pointing it directly to the URL returning the data?

It might work in certain cases.


Forum|alt.badge.img
  • Author
  • August 10, 2016
Hi, that URL required NTLM authorization, at least.

 


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • August 10, 2016
When you put a URL as the dataset, the Parameters should automatically be extended to provide you authentication options. Thanks for the interesting idea in any case.

 

 


Forum|alt.badge.img
  • Author
  • August 22, 2016
well, the csv could be returned not only from FeatureReader. Generic idea is to be able to split attribute which holds CSV data.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings