Skip to main content
Solved

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


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.

 

 

View original
Did this help you find an answer to your question?

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • 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

 


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