Reading Comma Delimited Files

J

John B. Lorenz

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
 
J

Joe Wright

John said:
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. :)
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top