CSV parsing with optional spaces between fields

G

Gergely Kontra

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 <[email protected]> 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 -----
 
C

Charles Calvert

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top