Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > CSV parsing with optional spaces between fields

Reply
Thread Tools

CSV parsing with optional spaces between fields

 
 
Gergely Kontra
Guest
Posts: n/a
 
      05-05-2005
Hi!

I'd like to parse a CVS file, which can contain whitespaces between
fields, but it seems, that the csv.rb in ruby 1.8.2 doesn't support
this. What can I do?

thx in advance
Gergo
--
+-[ Gergely Kontra <(E-Mail Removed)> http://www.mcl.hu/~kgergely ]------+
| PhD Student (Room:IB113) PGP ID: 0x7E3846BF Mobile+36 20)356 9656 |
| Budapest University of Technology and Economics ICQ# 175564914 |
+------------- "Olyan langesz vagyok, hogy poroltoval kellene jarnom!" -+



----- End forwarded message -----

--
+-[ Gergely Kontra <(E-Mail Removed)> http://www.mcl.hu/~kgergely ]------+
| PhD Student (Room:IB113) PGP ID: 0x7E3846BF Mobile+36 20)356 9656 |
| Budapest University of Technology and Economics ICQ# 175564914 |
+------------- "Olyan langesz vagyok, hogy poroltoval kellene jarnom!" -+


 
Reply With Quote
 
 
 
 
Charles Calvert
Guest
Posts: n/a
 
      10-26-2010
On Thu, 5 May 2005 22:45:54 +0900, Gergely Kontra <(E-Mail Removed)>
wrote in <(E-Mail Removed)>:

>I'd like to parse a CVS file, which can contain whitespaces between
>fields, but it seems, that the csv.rb in ruby 1.8.2 doesn't support
>this. What can I do?


Just in case someone stumbles across this in the Google archive, here
is the deal:

If the field is surrounded by quotation marks, any spaces outside
those quotation marks would be considered malformed.

If the field is not surrounded by quotation marks, then the space is
considered part of the field's content. If you don't want it, look at
String#strip and its cousins.
--
Charles Calvert
Moderator - alt.computer.consultants.moderated
Submission Address: http://www.velocityreviews.com/forums/(E-Mail Removed)
Contact Address: (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[CSS] how can I show spaces as spaces? Tomasz Chmielewski HTML 21 09-10-2009 06:43 PM
Best way to parse a csv...... a csv that has CRLF in the fields sso Java 20 04-26-2009 11:04 AM
Re: How to trim a String trailing spaces, but not leading spaces? Roedy Green Java 3 09-14-2008 02:10 AM
Re: How to trim a String trailing spaces, but not leading spaces? John B. Matthews Java 4 09-12-2008 05:28 AM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments