Skip to main content
Archived

CSV flattener

Related products:FME Form
  • August 9, 2016
  • 4 replies
  • 13 views

Forum|alt.badge.img

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 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.

4 replies

david_r
Celebrity
  • 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
Safer
Forum|alt.badge.img+21
  • Safer
  • 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.