|
Todd Lehman <lehman@javanet.com> wrote:
> I guess it's pretty obvious, mostly, but how are the delimiter characters
> typically encoded (specifically: comma, double-quote, and newline)?
I remember looking for this about a year ago, and I came across something
that looked very standardish. If I remember right, it's really silly.
You don't actually escape things. Fields are comma separated, and optionally
surrounded by quotation marks -- both strings and numeric fields. If you
need to represent a comma or a quotation mark, then the enclosing marks are
required. Commas-within-quotation-marks are just typed normally; to
represent a quotation mark in a field, you double it.
So:
blah,"blah","1",1,"blah,blah,blah","he said ""blah"""
I don't think that there is any way to encode a newline. Perhaps by just
doing:
blah,"blah
blah"
but I've got some sort of intuition that there's a problem with that. Maybe
not. It's certainly ugly. :)
Sorry I can't find any references -- too tired. :)
> What's a string? Anything matching /[^0-9]/ or not matching /^[0-9]+$/ ?
> (uh, plus any gunk for handling decimals and e+12 and all that funstuff).
There's no distinction made between a string and anything else....
> I just downloaded a "CSV" version of my PayPal history and I thought this
> was weird: it put _everything_ (all fields, that is) in double-quotes --
> even numerical fields. But then it didn't put the header fields in quotes.
Yup.
> And it did also put a trailing comma on each line (hmm).
I don't think that's right. Or helpful, even. :)
--
Matthew Miller ---> mattdm@mattdm.org
Quotes 'R' Us ---> http://quotes-r-us.org/
Boston University Linux ---> http://linux.bu.edu/
|
|
Message has 2 Replies:
Message is in Reply To:
| | CSV delimiters
|
| Is there any "official" or "reasonably standardized format" for CSV (_C_omma _S_eparated _V_alue) data? I guess it's pretty obvious, mostly, but how are the delimiter characters typically encoded (specifically: comma, double-quote, and newline)? In (...) (24 years ago, 23-Sep-00, to lugnet.admin.database, lugnet.off-topic.geek, lugnet.publish)
|
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Database
|
|
|
|