CSV output with delimiter at the end

202 views
Skip to first unread message

bnoeson

unread,
Dec 5, 2017, 6:05:28 AM12/5/17
to beanio-users
Hi,

I encounter a problem with my csv file generation.
I need to have a file with one record per line and have the delimiter at the end.
By default, the delimiter is present between the fields but not at the end. 
I tried to add the delimiter as the recordTerminator, but it removes the line separator as well, so I have all the records on 1 line, which is not what I want.
I also can't add the delimiter + System.getProperty("line.separator") as the recordTerminator because it asks for a char type.

I thought about adding a last field at the end with an empty string. It would do the work but it isn't a "clean" way to handle this. 

Do you see another solution to this?

Boris

Nico Schlebusch

unread,
Dec 5, 2017, 7:13:43 AM12/5/17
to bea...@googlegroups.com
Hi Boris,

I have the same requirements for a pipe delimited message.

I thought about adding a last field at the end with an empty string. It would do the work but it isn't a "clean" way to handle this.
That is also the way I am handling it at the moment, don't know of something else to use.

Your idea of adding the delimiter as part of the record terminator could also work if you want to sacrifice portability. I would then specify it in the mapping.xml file as:

  <stream name="myStream format="csv"> 
    <parser>
      <property name="recordTerminator" value=",\r\n" />
    </parser>


Kind regards,
Nico Schlebusch
nico...@gmail.com

--
You received this message because you are subscribed to the Google Groups "beanio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beanio+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


bnoeson

unread,
Dec 5, 2017, 7:53:48 AM12/5/17
to beanio-users
Ok, thanks for your reply. I will do it with an empty field so.

Kind regards,
Boris.
Reply all
Reply to author
Forward
0 new messages