Help - Search - Members - Calendar
Full Version: Export 2 CSV (Comma in fields)
Mp3tag Forums > Mp3tag - International > Development > Export
bahri
Hi All!
First thing Thanks to the authors for Mp3Tag.
I had a look at the help and forum but could not come up with a solution.
Normal practice for CSV (Comma Delimited) is when a field contains a comma it is enclosed in Parentisis(") so as the comma does not conflict with the delimiters.

My solution is below and it works, I enclose all fields in (") , but this bloats the file unnessarly

CODE
$filename(csv,ANSI)Title,Artist,Album,genre,Comment,Bitrate,Samplerate,Path
$loop(%_filename_ext%)"%title%","%artist%","%album%","%genre%","%Comment%","%_bitrate%","%_samplerate%","%_path%"
$loopend()build on %_date% with %_app% - the universal Tag editor - http://www.mp3tag.de/en/

Is there a way to code the mte file to only enclose with(") the fields containing commas?

I hope I explained myself enough.

Thanks all
Regards
bahri
DetlevD
QUOTE (bahri @ Jun 10 2011, 19:17) *
... Normal practice for CSV (Comma Delimited) is when a field contains a comma it is enclosed in Parentisis(") so as the comma does not conflict with the delimiters.
My solution is below and it works, I enclose all fields in (") ...
Is there a way to code the mte file to only enclose with(") the fields containing commas?

Speaking of CSV, SSV, TSV and so on similar file formats ... summarized under the term CSV format.

Regarding CSV file format there exist no normal practice at all, because there is no standard defined, but there are somewhat common behaviours around in the world.

You have to know, that Mp3tag is per se not CSV ready.

But Mp3tag can create an export script, which outputs a CSV formatted text file.
Mp3tag cannot auto-detect the format of an input file, which is a CSV file.

When using the converter "Textfile - Tag" the user has to define a specific set of field masks for the entire textline. This way a CSV format can be simulated.

For both cases, inputting data and outputting data, the user is responsible to provide the right format.
Do not forget that the xSV delimiter character may be regional depending, can be comma or semicolon, such like numbers with decimal point with thousand comma resp. decimal comma with thousand point.

The most important thing is, that the two involved applications can talk to each other via a common file format resp. data structure.
Mp3tag is free to give this decision to your own inspiration and systematics.

One method would be, to enclose all values into Double Apostrophes and choose a delimiter that is common between the sender and receiver application.
You have to take into account that Mp3tag as sender cannot automatically escape the Double Apostrophe, when a tag-field already contains a Double Apostrophe.
Same is valid for Mp3tag as receiver, when a CSV field contains an escaped Double Apostrohe, Mp3tag cannot automatically unescape this field data.
You have to write your own Escape/Unescape scripting sequence.

Another method would be - when the other application can understand - to use no Double Apostrophes at all and use any delimiter character, which is not used in any data field, for example choose one character from this set '*,|,÷,°,■,±,­¦,¤'.

You can also use a three character delimiter sequence string between the data fields, for example ' ¤ ', if the other application can handle this.

DD.20110610.2028.CEST
bahri
Hi!
Thanks for your response, much obliged.
Like I said I managed to solve my problem somehow but your reply
adds to my knowledge and for this I thank you.
I like the open structure of Mp3Tag and how it can be adjusted to do things.

Thanks again

Regards
bahri
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.