Skip to main content
Question

Write "" in a csv


vijays
Forum|alt.badge.img+2

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

 

 

 

3 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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.


vijays
Forum|alt.badge.img+2
  • Author
  • February 4, 2019
redgeographics wrote:

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


redgeographics
Celebrity
Forum|alt.badge.img+49
vijays wrote:

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.


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