> CSVs are much trickier than a lot of people realize to handle in my
> experience. For example, there are two separate CSV formats -- one the
> world uses and one Microsoft uses.

Actually, there is no standard for CSV. There are just about as many
"formats" as there are implementations. Consequently, CSV is not a
particularly good interchange format.

It's my understanding that what we commonly refer to as the CSV format was
popularized by Excel. Other applications, including those from Microsoft,
have used formats similar. In many cases, the format is loosely based on the
Excel format.

For instance, I don't believe the Excel format allows embedded carriage
returns and line feeds. Excel also trims leading zeros and white space. Many
other implementations do not. They will also allow carriage returns and line
feeds provided the data in question is enclosed in quotes.

> How do you know which type you're
> going to get? Secondly, did you know that you can have carriage
> returns within a given field, and it's perfectly valid?

Be careful. By using the word "valid" you're suggesting that CSV can be
validated against something akin to a DTD or that there's some overriding
standard. This is not the case. The Excel format is the closest thing to a
de facto standard, but it is also one of the most limiting.

Consequently, what one application considers valid is not necessarily what
another considers valid. You can have two CSV files which are perfectly
valid in their own context but which can't be shared with other
applications.

There are quite a few articles on CSV formatted files and ways to parse
them. I found this one in particular to be useful when I was writing a
simple CSV parser:

  http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm

Ben Rogers
http://www.c4.net
v.508.240.0051
f.508.240.0057


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189915
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to