Skip to main content
Solved

How to read csv (dynamic) and write csv (dynamic) with filename plus postfix?

  • March 5, 2018
  • 2 replies
  • 143 views

Forum|alt.badge.img

I want to read csv files with different schemas but with some attributs which are part of all csv files:

file1in: attribute1, attribute2, attributeA, attributeB, attributeC

file2in: attributeD, attributeE, attribute1, attribute 2, attributeF, attributeG

Then I want to do some processing and write the files with some additional attributes to new files:

file1out: attribute1, attribute2, attributeA, attributeB, attributeC, attributeX, attributeY

file2out: attributeD, attributeE, attribute1, attribute 2, attributeF, attributeG, attributeX, attributeY

File names for output are the filenames of input with additonal postfix like "_transformed":

<filename1in> => <filename1in>+"_transformed" (<filename1out>

How can I do this? I have tried to use a csv writer with dynamic properties but then I get resulting filenames of "CSV". If I change the feature type names from "format names" to "file names" in the csv reader, then I get the filenames but I loose the original attributs from the input csv files.

Anyone has an idea how to solve this?

Best regards,

Frank

Best answer by jdh

Create an attribute (ex _filename) that is fme_basename_transformed.

 

On the csv writer set the file name to that attribute, but set the Schema definition name to fme_feature_type (not default from CSV name).

 

In the User attributes tab add the additional attributes you created.

 

 

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.

2 replies

jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • Best Answer
  • March 5, 2018

Create an attribute (ex _filename) that is fme_basename_transformed.

 

On the csv writer set the file name to that attribute, but set the Schema definition name to fme_feature_type (not default from CSV name).

 

In the User attributes tab add the additional attributes you created.

 

 


Forum|alt.badge.img
  • Author
  • March 6, 2018

Hello Joanna!

Thank you for your hint! Simple and works for me :-)

Best regards,

Frank