File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to skip commas, in CSV file generator?

 
Simpson Kumar
Ranch Hand
Posts: 261
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem while creating the CSV file. I use to write the CSV file by separating with delimiter "|", this works fine if any text doesn't have any commas (","). The problem is if any text contains comma, then the remaining text continues to next cell, which is wrong. look into the examples

Perfect line:

10|001300221|SIMSON||WILLIAMS|A|20080818|1525|8753||HOLZGRAFE|| PEDIATRICS INTENSIVE CARE|ASSISTANT PROFESSOR/CLINICIAN|GUH PASQUERILLA HEALTHCARE CNT

In the above case, CSV writes in the same cell and then fine.

with comma:


10|001300221|SIMSON||WILLIAMS|A|20080818|1525|8753||HOLZGRAFE|| PEDIATRICS, INTENSIVE CARE|ASSISTANT PROFESSOR/CLINICIAN|GUH PASQUERILLA HEALTHCARE CNT


look at the bold sentence, there you see the comma and the line after comma is seprating to next cell.
I don't want like that, is there anyway to skip that comma and need as it is in the written file?


 
Fred Hamilton
Ranch Hand
Posts: 684
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar Kuchipudi wrote:I have a problem while creating the CSV file. I use to write the CSV file by separating with delimiter "|", this works fine if any text doesn't have any commas (","). The problem is if any text contains comma, then the remaining text continues to next cell, which is wrong. look into the examples

Perfect line:

10|001300221|SIMSON||WILLIAMS|A|20080818|1525|8753||HOLZGRAFE|| PEDIATRICS INTENSIVE CARE|ASSISTANT PROFESSOR/CLINICIAN|GUH PASQUERILLA HEALTHCARE CNT

In the above case, CSV writes in the same cell and then fine.

with comma:


10|001300221|SIMSON||WILLIAMS|A|20080818|1525|8753||HOLZGRAFE|| PEDIATRICS, INTENSIVE CARE|ASSISTANT PROFESSOR/CLINICIAN|GUH PASQUERILLA HEALTHCARE CNT


look at the bold sentence, there you see the comma and the line after comma is seprating to next cell.
I don't want like that, is there anyway to skip that comma and need as it is in the written file?




it doesn't look to me like the line after the comma is separating to the next cell.

But anyways, I think I know what you mean to show. you say you are using the | as a delimiter, but somehow the comma is being used also as a delimiter? How is that happening?

edit: ok maybe you are using a class or utility that automatically parses with comma separators? If so I would ask why, if you don't want to parse according to commas?
 
Nikki Agr
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about you embed that string which contains a comma within double quotes?
 
Mathew Lee
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend to use something unique say like $@$ etc which clearly distinguishes
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic