tags:

views:

87

answers:

4

I have a CSV file that has lists of values for some fields. They're stored in the database as HTML "ul" elements, but I want to convert them into something more spreadsheet-friendly.

What should I use as my delimiter? I could use escaped commas, pipes, semicolons, or pretty much anything else. Is there some kind of de facto standard people use for this?

+1  A: 

It depends largely on the values you are trying to separate. For example, if you're expecting numeric values, it would be unwise to use comma or period as your delimiter. Same goes if the values expect hashes. or pipes

Use a character that has the least possibility of being used in the content. To do this, you might want to analyze your data first so you can easily decide what delimiter to use.

Randell
Ofcourse, it depends on data!
Janis Veinbergs
It depends on the data but I was hoping there was some kind of convention ...
Rafe
+1  A: 

I always liked the TAB character as a separator - works well when importing into Excel too.

Peter Sankauskas
A: 

Quotes around the item is for this

123, hello, "a, b, c, d", 29
Noon Silk
This was one of the possibilities I considered. I think commas are the most logical internal delimiter. The only downside is that this approach may make the CSV file confusing to look at.
Rafe
No-one is ever looking at CSV's (in the raw format) are they? Something like excel will break it out appropriately (well, pending bugs, which it has had).
Noon Silk
This is the solution I went with.
Rafe
A: 

Pipes with quotes as text qualifiers have worked best for me. It makes it easier to read when you open the data file in NotePad++ too.

dr