Skip to main content
Solved

how to put quotes around stings when feature writer writes a csv?

  • December 7, 2018
  • 6 replies
  • 293 views

nicholas
Contributor
Forum|alt.badge.img+14

I am using FeatureWriter to ouput a text file.

It does not put quotes around string attributes like it should.

I want

"2018-12-07 09:30:00","Canungra (Defence)",0

I get

2018-12-07 09:30:00,Canungra (Defence),0

The third column is numeric and should not have quotes

Best answer by nicholas

I solved it by switching the FeatureWriter from Format: CSV to format Test File

I used Attreibute creator to concatenate three columns into one (text_line_data) with " and , exactly where I want them.

I also used a Creator and AttributeManager to create the column names (separated by commas) as the first line

So, my solution was to avoid the csv writer and use the text file writer instead. More work, but far more control.

What I would really like is for the CSV writer to allow the quotes to be set on a column by column basis

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.

6 replies

nicholas
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • December 7, 2018

I tried StringReplacer and it does not work


danilo_fme
Celebrity
Forum|alt.badge.img+52
  • Celebrity
  • December 7, 2018

Hi @nicholas

I re-criated here your case with the AttributeCreator:

 

After, the transformer AttributeSplitter to split in " , ". The list of attributes was created:

_list{0}

_list{1}

_list{2}

 

I concatenated with StringConcatenator using this configuration:

"@Value(_list{0})","@Value(_list{1})",@Value(_list{2})

 

 

 

 

Thanks,

Danilo

 


nicholas
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • Best Answer
  • December 7, 2018

I solved it by switching the FeatureWriter from Format: CSV to format Test File

I used Attreibute creator to concatenate three columns into one (text_line_data) with " and , exactly where I want them.

I also used a Creator and AttributeManager to create the column names (separated by commas) as the first line

So, my solution was to avoid the csv writer and use the text file writer instead. More work, but far more control.

What I would really like is for the CSV writer to allow the quotes to be set on a column by column basis


takashi
Celebrity
  • December 7, 2018

If you need to always quote the 1st and the 2nd columns, you can easily do it using the StringConcatenator with the Overwrite Existing Attributes option, like this. Assuming attribute names for the 1st and the 2nd columns are "attr1" and "attr2".


erik_jan
Contributor
Forum|alt.badge.img+26
  • Contributor
  • December 7, 2018

The Parameters for the CSV writer in the FeatureWriter contain these to add quotes to the output values:


nicholas
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • December 9, 2018

The Parameters for the CSV writer in the FeatureWriter contain these to add quotes to the output values:

Setting "Qualify Field Values" to Yes will force quotes on all columns, including numeric fields. I do not want quotes on numeric fields