CSV parsing with optional spaces between fields

Discussion in 'Ruby' started by Gergely Kontra, May 5, 2005.

  1. 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 <> 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 <> 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!" -+
     
    Gergely Kontra, May 5, 2005
    #1
    1. Advertising

  2. On Thu, 5 May 2005 22:45:54 +0900, Gergely Kontra <>
    wrote in <>:

    >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:
    Contact Address:
     
    Charles Calvert, Oct 26, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GIMME
    Replies:
    2
    Views:
    877
    GIMME
    Feb 11, 2004
  2. Marcus Leon
    Replies:
    1
    Views:
    3,299
    Marcus Leon
    Jun 30, 2003
  3. John B. Matthews
    Replies:
    4
    Views:
    671
    John B. Matthews
    Sep 12, 2008
  4. Roedy Green
    Replies:
    3
    Views:
    627
  5. sso
    Replies:
    20
    Views:
    2,676
    Martin Gregorie
    Apr 26, 2009
Loading...

Share This Page