d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java To Csv > Special Chars " \
Add Reply New Topic New Poll
Member
Posts: 5,269
Joined: Oct 18 2006
Gold: 21,400.00
Feb 3 2014 05:38pm
I want to write from Java to a CSV this exact phrase in one cell "hi,hi"

I keep getting it butchered or split into multiple cells. My real purpose is to write a whole HTML block of code into one CSV cell.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 3 2014 05:41pm
You are going to need to elaborate.
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
Feb 3 2014 06:55pm
You can write a csv file with a different delimiter

I wrote an entire project that exported data using the ^ delimiter. You can easily go into excel and choose ^ as your separating charachter and then you won't need to worry about commas

Although I should have done my research when I did the project , found this via stack exchange
"Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes."

This post was edited by oOn on Feb 3 2014 06:57pm
Member
Posts: 5,269
Joined: Oct 18 2006
Gold: 21,400.00
Feb 4 2014 10:39pm
I figured it out. To write "hi,hi" into a csv cell you will need to write:

csvOut.print("""hi,hi""");
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
Feb 5 2014 12:18am
Quote (xandumx @ Feb 5 2014 04:39am)
I figured it out.  To write "hi,hi" into a csv cell you will need to write:

csvOut.print("""hi,hi""");


That's exactly what I said
Member
Posts: 5,269
Joined: Oct 18 2006
Gold: 21,400.00
Feb 5 2014 11:39am
Quote (xandumx @ Feb 4 2014 09:39pm)
I figured it out.  To write "hi,hi" into a csv cell you will need to write:

csvOut.print("""hi,hi""");


opps, forgot to escape in java... csvOut.print("\"\"hi,hi\"\"");
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll