From: Stanza on
What is the easiest way of reading a line at a time through a textual CSV
file, and then extracting the comma-separated elements from each line?

From: Scott McPhillips [MVP] on
"Stanza" <stanza(a)devnull.com> wrote in message
news:-OqdnbEEGM-UF8XWnZ2dnUVZ8r-dnZ2d(a)brightview.com...
> What is the easiest way of reading a line at a time through a textual CSV
> file, and then extracting the comma-separated elements from each line?
>

CStdioFile::ReadString will read a text file a line at a time.

The CString class provides everything you need to parse the lines.
CString::Find can be used to find the next comma. CString::Mid can be used
to extract an element.

--
Scott McPhillips [VC++ MVP]

From: James Juno on
"Scott McPhillips [MVP]" wrote...
> "Stanza" wrote...
>> What is the easiest way of reading a line at a time through a textual CSV
>> file, and then extracting the comma-separated elements from each line?
>>
>
> CStdioFile::ReadString will read a text file a line at a time.
>
> The CString class provides everything you need to parse the lines.
> CString::Find can be used to find the next comma. CString::Mid can be
> used to extract an element.
>

You might also consider using CString::Tokenize() to parse the line.

-JJ

From: Pete Delgado on

"Stanza" <stanza(a)devnull.com> wrote in message
news:-OqdnbEEGM-UF8XWnZ2dnUVZ8r-dnZ2d(a)brightview.com...
> What is the easiest way of reading a line at a time through a textual CSV
> file, and then extracting the comma-separated elements from each line?
>

In addition to the other replies that you have recieved, you may wish to use
C++ standard library regular expressions provided in the TR1 extensions.
They are quite easy to use and would likely need less code than the other
methods mentioned and above all are portable.

-Pete


From: Tom Serface on
This is a handy tokenizer that might work for you:

http://www.codeproject.com/KB/string/ctokenex.aspx

Tom

"Stanza" <stanza(a)devnull.com> wrote in message
news:-OqdnbEEGM-UF8XWnZ2dnUVZ8r-dnZ2d(a)brightview.com...
> What is the easiest way of reading a line at a time through a textual CSV
> file, and then extracting the comma-separated elements from each line?
>