Skip to main content
Question

Write "" in a csv

  • January 28, 2019
  • 3 replies
  • 34 views

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

 

 

 

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.

3 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

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

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+62

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.