How to Parse a CSV formatted text file

J

Joe Wright

Dietmar said:
So, you are saying this is not at all a homework assignment but rather a
request from a Microsoft engineer asking for correct code dealing with
their files?

I'm not sure I follow you. It's certainly not my homework assignment.
 
P

Phlip

Joe said:
I'm not sure I follow you. It's certainly not my homework assignment.

The question is not whether it's homework (or whether a very similar
question arrived within a few hours).

The question is whether the group is asked to do someone's learning for
them.
 
P

Programmer Dude

David said:
Excel expects quotes within the field to be doubled. In fact, I
would go so far as to say FoxPro is wrong.

I would agree FoxPro is wrong. It appears to require (based on the
spec presented upthread), seeing the two-character sequence (",) or
the two-character sequence ("<newline>). That is, if the field
started with the (") character.

I might look for the three-character sequence (",") (or "<newline>),
but I still think this is a broken spec. Without being able to
escape the double-quote, you simply can't guarentee that there isn't
a valid delimiter sequence instring.

Also, this spec requires control of the CSV *emitter* (which, to me,
lacks robustness). The spec requires the writer of the values be
sure to not include spaces--in this case, between the final quote
and the comma. I'd rather a CSV reader that can handle:

" " , foobar , 42 , "Hello, World!" ,, , "Jonas ""J"" Jamison",

Without worrying about padding spaces around the commas.

What's maybe more an issue is how quotes are escaped. One standard
(used by MS and others) is doubling the quote. The other common one
uses an "escape char", such as the backslash. A *really* good CSV
parser should, IMO, detect both *AND* allow for single-quoting as
well as double-quoting.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top