Skip to main content

Hi,

 

A simple question ->

I want to write "" value in a field in a csv file using csv writer.

When this csv file is opened in notepad, the value should look at "" and not as """""".

E.g. Note the third column, that is how it should be visible.

ID,Name,Comment

12,Vijay,""

13,Sambhe,""

 

Its odd but that is the requirement. I can add a workspacerunner, read csv as texfile and replace """""" as "" and write to a textfile but I want this to be done in a single workspace.

 

Thanks,

Vijay

 

 

 

On the CSV writer parameters you can set the option "Qualify Field Values" to No, that will disable that behaviour. However, if you have a field which contains a comma (or whatever you set as the field separator) you'll have a problem.


On the CSV writer parameters you can set the option "Qualify Field Values" to No, that will disable that behaviour. However, if you have a field which contains a comma (or whatever you set as the field separator) you'll have a problem.

Hi,

Thanks for looking into this.

I had tried that but then the default value of "" comes as blank value in the csv file.

I want the value in the csv file (if you view by opening it in notepad) to be written as

100,200,300,"","","",500

 

See the quotes.

Thanks,

Vijay


Hi,

Thanks for looking into this.

I had tried that but then the default value of "" comes as blank value in the csv file.

I want the value in the csv file (if you view by opening it in notepad) to be written as

100,200,300,"","","",500

 

See the quotes.

Thanks,

Vijay

Okay, I think I figured it out.

First of all you should use a NullAttributeMapper to map null (or empty/missing) values to "". But in the writer parameters you also need to set the Field Qualifier Character to something other than "

I'm also not sure if other software will read the file properly. For example if you want to read the same file in FME you'll need to set the Field Qualifier Character on the reader too. Same with Excel.


Reply