Skip to main content
Question

Add blank line between field names and data into CSV Writer


farfar
Contributor
Forum|alt.badge.img+11
Hi All,

 

I look for a method that can add a blank line between field names and data into CSV Writer.

 

Any idea? 

 

Thanks an advance.

 

FarFar

20 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 11, 2014
Hi FarFar,

 

 

There may be several ways.

 

An easy way:

 

Add a Creator transformer to the workspace and connect it to the CSV writer.

 

Geometry Object: Null

 

Number to Create: 1

 

Create At End: no

 

 

But the CSV writer will write commas anyway. If you don't want to write commas, the solution will be a little more complicated.

 

Wouldn't you like to write commas into the line?

 

 

Takashi

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 11, 2014
Hi Takashi,

 

Thank you for your response.

 

No. I don't like to write commas into the line.

 

 

FarFar

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 11, 2014
Does'nt CSV always need a separator-character?  (wether it be comma or one of the other options)

 

Space would need be enclosed in these separators.

 

 

 

Maybe you should write it as a txt. And use 2 or more spaces as separator.

 

 ( and make sure attribute values have max. 1 space in succesion max, if at all)

 

Entering 2xnewline character for blank line is of course not an issue, thats easy.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 12, 2014
Remove the CSV writer; add a Text File writer instead.

 

Insert a StringConcatenator before the writer to create a csv line (comma-separated attribute values) for each feature. Set the concatenated attribute name to "text_line_data".

 

Add a Creator to create a feature; connect an AttributeCreator to add an attribute named "text_line_data" to the feature, set the value to comma-separated field names followed by one newline character. And then send the feature to the writer.

 

 

Note that a value should be surrounded by double quotations before the concatenation if it contains a comma.

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 12, 2014
Hi,

 

I'm following you method but i dont show a blank line !

 

this is my example to do it : 

 

 

Any idea?

 

Thanks an advance.

 

Farfar

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 12, 2014
One possible reason is that the newline was not set properly. But it cannot be checked in the screenshot.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 12, 2014
This is an example of setting the field names + a newline character with the AttributeCreator in FME 2013.

 


farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 12, 2014
I did exactly the same but i haven't the blank line between fields names and data!!

 

FarFar

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 12, 2014
You need to have two newlines in a row for a blank line....

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 12, 2014
ok, that did'nt work either.

 

 

How about this then?

 

 

If you dont want last blank line, remover last line_number...after sorting.

 

 

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 12, 2014
Hi,

 

Always KO.

 

i add 2 newlines likes :

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 13, 2014
Good to hear you've accomplished it.

 

 

I was able to get the required result with just one newline character, so I'm not sure why you had to add two newlines.

 

I tested it with FME 2014 SP4 and 2013 SP4.

 

Which version are you using?

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 16, 2014
FME 2013 SP2.

 

My problem is not resolved :)

 

i will migrate to SP3 to test if its OK.

 

 

Farfar

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 16, 2014
i'd say to migrate to SP4

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 17, 2014
Hi,

 

I installed SP4 but my problem isn't resolved ! 

 

Any idea ?

 

 

Thanks

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 17, 2014
Hi,

 

I installed SP4 but my problem isn't resolved ! 

 

 

Any idea ?

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 17, 2014
Check if this example works in your environment.

 

Download (https://drive.google.com/file/d/0B0ufVP2t0eApVXl3V21kZ1AzX1k/view?usp=sharing)

 

I can always run it successfully with FME 2013 SP4.

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 17, 2014
Thanks a lot Takashi. It works your example. 

 

I compared a two workbench and the difference is that my writer is saved as a txt file. So no blank line between fields names and data. 

 

If a specify that is a csv file writer, it works like your example.

 

 

Thank you.

 

Farfar

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • December 17, 2014
Erratum : 

 

 

Thanks a lot Takashi. It works your example. 

 

I compared a two workbench and the difference is that my writer is saved as a txt file with .txt extension. So no blank line between fields names and data. 

 

If the writer is a text file WITH CSV EXTENSION, it works like your example.

 

 

Thank you.

 

Farfar

 

 

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 17, 2014
the workspace pic i posted inserts a blanklines into a txt file (no csv extension needed). Try it out.

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