Question

Add blank line between field names and data into CSV Writer

  • 11 December 2014
  • 20 replies
  • 41 views

Badge
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

Userlevel 2
Badge +17
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
Badge
Hi Takashi,

 

Thank you for your response.

 

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

 

 

FarFar
Badge +3
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.
Userlevel 2
Badge +17
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.
Badge
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
Userlevel 2
Badge +17
One possible reason is that the newline was not set properly. But it cannot be checked in the screenshot.
Userlevel 2
Badge +17
This is an example of setting the field names + a newline character with the AttributeCreator in FME 2013.

 

Badge
I did exactly the same but i haven't the blank line between fields names and data!!

 

FarFar
Badge +3
You need to have two newlines in a row for a blank line....
Badge +3
ok, that did'nt work either.

 

 

How about this then?

 

 

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

 

 
Badge
Hi,

 

Always KO.

 

i add 2 newlines likes :

 

Userlevel 2
Badge +17
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?
Badge
FME 2013 SP2.

 

My problem is not resolved :)

 

i will migrate to SP3 to test if its OK.

 

 

Farfar
Badge
i'd say to migrate to SP4
Badge
Hi,

 

I installed SP4 but my problem isn't resolved ! 

 

Any idea ?

 

 

Thanks
Badge
Hi,

 

I installed SP4 but my problem isn't resolved ! 

 

 

Any idea ?
Userlevel 2
Badge +17
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.
Badge
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
Badge
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

 

 
Badge +3
the workspace pic i posted inserts a blanklines into a txt file (no csv extension needed). Try it out.

Reply