Reading Comma Delimited Files

Discussion in 'C Programming' started by John B. Lorenz, Jul 7, 2003.

  1. I'm attempting to write an input routine that reads from a comma delimited
    file. I need to read in one record at a time, assign each field to a field
    array and then continue with my normal processing. I am having no luck at
    all finding different routines written in C to read delimited files of any
    kind. I have a few ideas of how I might go about this but I bet I'm
    re-inventing the wheel and there already exists some efficient code out
    there already? Im not an expert in C but know it well enough to get by most
    of the time. Am I missing something obvious?

    Thanks

    John
     
    John B. Lorenz, Jul 7, 2003
    #1
    1. Advertising

  2. John B. Lorenz

    Joe Wright Guest

    John B. Lorenz wrote:
    >
    > I'm attempting to write an input routine that reads from a comma delimited
    > file. I need to read in one record at a time, assign each field to a field
    > array and then continue with my normal processing. I am having no luck at
    > all finding different routines written in C to read delimited files of any
    > kind. I have a few ideas of how I might go about this but I bet I'm
    > re-inventing the wheel and there already exists some efficient code out
    > there already? Im not an expert in C but know it well enough to get by most
    > of the time. Am I missing something obvious?
    >

    The real problem is absolutely non-trivial. The first is natural
    language. What's the difference between a delimiter and a separator? Did
    we mean 'comma delimited' or did we really mean 'comma separated'?
    Probably 'separated'. Regard this text line:

    010,"Joe","","Wright, Jr.",20030707,1.1,,"Y"

    What would you make from that? We can see that 'fields' are separated by
    commas. We see that 'character' fields are delimited with '"'. Note the
    delimiter allows commas within character fields. But, in fact, the line
    itself does not contain enough information for us to determine what to
    do its fields. Before you can make any sense out of this, someone has to
    tell about the FORMAT of the thing or you have to be a good guesser. :)
    --
    Joe Wright mailto:
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, Jul 8, 2003
    #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. Yama

    Comma Delimited

    Yama, Dec 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    407
    Ken Cox [Microsoft MVP]
    Dec 16, 2003
  2. Luis Esteban Valencia

    Read Comma Delimited File

    Luis Esteban Valencia, Jul 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,820
    Paul Clement
    Jul 27, 2005
  3. Hilary Cotter

    ? about reading a comma delimited file

    Hilary Cotter, Sep 4, 2003, in forum: C Programming
    Replies:
    4
    Views:
    745
    Dave Thompson
    Sep 15, 2003
  4. RyanL
    Replies:
    6
    Views:
    702
    Paul McGuire
    Aug 28, 2007
  5. Replies:
    8
    Views:
    190
Loading...

Share This Page