Page 1 of 1

Running replace function on entire flatfile

Posted: Wed Apr 28, 2021 7:02 pm
by Nismon8er
I am running DBWriter -> Reformat -> StructuredDataWriter .... this works fine

What I need to do after that is run FlatFileReader (on the resulting file from the StructuredDataWriter above) -> Reformat -> FlatFileWriter because I need to replace all instances of double single quotes '' to NULL but im not sure how to go about this since I always need metadata and im not sure what that will be if I want to do this for the entire file

If someone knows of another way to do this let me know

Re: Running replace function on entire flatfile

Posted: Tue May 11, 2021 2:04 pm
by szabol
Hello there!

I see two answers to your question.
In first one you only need FlatFileReader and FlatFileWriter.
1. Right click on FlatFileReader with linked file and select "Extract metadata"
2. Click "Next" and in "Quote character:" dropbox choose quotes and click "Finish"
3. In FlatFileWriter set "Quoted strings" attribute to "false"

When you run the graph data should be written now without the quotes.

Second solution utilizes "Reformat" component. There you read whole file as one record and use "replace" function
to get rid of the quotes.
1. Create new metadata with one field
2. Click on the record and delete values from "Record delimeter" and "Default delimeter"
3. Set "EOF as delimeter" in "Advanced" to true
4. In "Reformat" component use "replace" function
e.g. $out.0.field1 = replace($in.0.field1,"'","")

I've attached a file with above mentioned solutions so you can have a look.