• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to skip commas, in CSV file generator?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about you embed that string which contains a comma within double quotes?
 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend to use something unique say like $@$ etc which clearly distinguishes
 
reply
    Bookmark Topic Watch Topic
  • New Topic