If you want commas within your fields, you'll probably want to use a different delimiter. Excel is pretty flexible on this, if that's what you're importing to. Semi-colon, space, tab are standard enough to get radio button on their import tool, but you can specify whatever you like. Pick something that's not going to be found in actual data.
I've seen a regular report that was "|~\"-delimited, presumably to avoid having the delimiter turn up in a field.
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187
Jon.kiparsky are you implying that semi-colons can be used instead of commas as delimeter for .csv files?
Yes. Excel, in particular, has the ability to import ".csv" files with arbitrary delimiters. Look under the "Data" menu, there's an Import Data item which opens up an import wizard. In that wizard, you'll be given the option to select from a few standard delimiters, or to enter one of your choosing. It'll even preview how a file will look when split on a particular delimiter.
So if you build your .csv file with something like
line=array[1]+";"+array[2]+";"+array[3]+";"+array[4]+";"...+System.getProperty("line.separator");
you should be able to import that to excel with no trouble. (presumably, you'd use a slightly more sophisticated technique to build the strings, but I assume you know how that goes)
You can also use tab as a delimiter, if you want to make the file a little more human-readable.
EDIT: my bad - I gave you a line of java instead of perl. Forgot where I was. Please make the obvious substitutions! :)
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187