By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,137 Members | 2,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,137 IT Pros & Developers. It's quick & easy.

Reading Comma Delimited Files

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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:jo********@earthlink.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.