Problem exporting CSV file - unexpected results

I obtain results I did not expect when running this csv export script on a collection of FLAC files:

$filename(txt,utf-8)LENGTH,ARTIST,TITLE,ALBUM,LABEL,YEAR,COMPILATION
$loop(%_path%)%length%,%artist%,%title%,%album%,%label%,%year%,%compilation%
$loopend()

If any of the Vorbis comments have commas in them, extra columns are generated. Is there a way to alter this script so that the integrity of each of the tags is maintained? For example, if the title of a song has a comma in it, two columns in the resulting Excel spreadsheet are created. Of course the column headings are wrong and I cannot use the spreadsheet to map the metadata into another application.

For example, an old American folk song titled "When You and I Were Young, Maggie" causes a problem in that the resulting TITLE column entry is "When You and I Were Young" and the ALBUM column contains "Maggie" instead of the correct value "Bluegrass Guitar Duets" and so on for the remaining columns in that row.

Any help you can provide would be greatly appreciated!

Dennis, aka "d2b"

you could modify the output mask to:
"%length%","%artist%","%title%","%album%","%label%","%year%","%compilation%"
or
%length%$char(9)%artist%$char(9)%title%$char(9)%album%$char(9)%label%$char(9)%year%$char(9)%compilation%
and then tell Excel that the tab character separates the fields.

Thank you very much! That indeed solved that issue.

May I now ask a follow-on question? Here it is:

The "COMPILATION" tag is a Boolean expression. That is, COMPILATION=1 means that the song is from an album that is a compilation by different artists. If the artist is the same for all files in an album, the COMPILATION tag is missing from the file. I would like the following action to take place as part of this script prior to opening the resulting *.csv file in Microsoft Excel:

If COMPILATION=1, then the entry for that row in the COMPILATION column becomes "COMP". If the COMPILATION tag is missing, then the entry in the COMPILATION column for that row becomes "ALBUM"

I know this can be done in the Excel application, but that requires manual intervention after the *csv file is opened. I'd prefer to avoid that if the task can be automated as part of the mp3tag export process.

Thanks again for helping me.

Dennis, aka "d2b"

Replace the plain %compilation% with
$if($eql(%compilation%,'1'),'COMP','ALBUM')

Once again, you have answered my question perfectly. Thank you!!

Dennis, aka "d2b"