On Tue, 11 Jan 2005 11:11:27 -0500, Ben Rogers <[EMAIL PROTECTED]> wrote: > > 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.
Which further emphasizes my point that basic ColdFusion solutions of looking for carriage returns and the like is not a robust way to solve this problem. > > 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. Well, I would have said "validated" if I meant to a DTD or XSD or some such, and I've never even heard of any "validation" mechanisms for CSV files other than parsing the file itself. > > 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. Sure, but the same could be said of almost any transport medium. For example, an XML file might be valid on one system, but not necessarily on another if the DTD/XSD it validates against is different. > > 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 That's a good one. I'm particularly interested in the CSV to XML converter they posted. Thanks for the link. Regards, Dave. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189930 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