Help - Search - Members - Calendar
Full Version: Export to csv problem with multiple entries in tags
Mp3tag Forums > Mp3tag - International > General Discussion
m4rk
Hi,

I am successfully exporting my collection details to csv and can bring it into excel. I use | as a deliminator. (The default ; didn't work because too many titles have that too). Some of my tags have multiple entries, typically genre, and use // as separator for them. The exported file seems to drop anything after // in genre so I only get the first genre item in the csv

Can I do anything fix this?

Thanks Mark
pone
from the help files:
ZITAT
$meta(x)
returns all values of field x (e.g. $meta(artist)). If multiple values of that field exist, they are separated with ", ".

$meta(x,n)

returns the nth value of field x (where n starts at 0, e.g. $meta(artist,1)).

$meta_sep(x,sep)

returns all values of field x (e.g. $meta_sep(artist,; )). If multiple values of that field exist, they are separated with sep.


http://help.mp3tag.de/main_scripting.html#metadata

m4rk
QUOTE (pone @ Feb 22 2012, 10:42) *



Hi thanks for that.... looks I need help for the help files!! I have no idea what that all means. It is fun learning though biggrin.gif

The more I use mp3tag the more I am impressed with it. You can do just about anything but it takes quite a bit learning for a novice and much testing to figure it out.

Thanks, I think that has pointed me in the right direction
pone
When you are exporting your tags, you are using an export script.
Open that script and replace all instances of %genre% with $meta(genre)
You have to do this with all tag fields where you have multivalue tags.
m4rk
QUOTE (pone @ Feb 22 2012, 11:14) *
When you are exporting your tags, you are using an export script.
Open that script and replace all instances of %genre% with $meta(genre)
You have to do this with all tag fields where you have multivalue tags.



Great, that tip helps a lot.

I had found the export scripts and made a simple change. I changed the default delimiter and saved it as a new script but I must admit to being a bit clueless as to how they worked. Is there a help section to explain how the looping part works? I didn't see it in 'scripting' help section?

Mark
pone
ZITAT(m4rk @ Feb 22 2012, 12:03) *
Is there a help section to explain how the looping part works? I didn't see it in 'scripting' help section?


yes, in the export help section http://help.mp3tag.de/options_export.html#syntax :
ZITAT
$loop(%fieldname%) starts a new loop. The loop data is sorted by the fieldname.
$loopend() ends a loop.
If you want to limit the loop output to a certain number of entries, simply use $loop(%fieldname%,num). This is useful to eliminate duplicate records (num=1).



So if you have something like
QUELLTEXT
$loop(%_filename_ext%)%title%;%artist%;%album%;
$loopend()

the loop writes %title%;%artist%;%album%; + linebreak for every new %_filename_ext%.


Whereas this loop
QUELLTEXT
$loop(%album%)%albumartist%;%album%;%year%
$loopend()

would write %albumartist%;%album%;%year% + linebreak for every new %album%. So it would skip all files with the same %album% value after writing the values of the first file.
m4rk
QUOTE (pone @ Feb 22 2012, 12:29) *
yes, in the export help section http://help.mp3tag.de/options_export.html#syntax :



So if you have something like
CODE
$loop(%_filename_ext%)%title%;%artist%;%album%;
$loopend()

the loop writes %title%;%artist%;%album%; + linebreak for every new %_filename_ext%.


Whereas this loop
CODE
$loop(%album%)%albumartist%;%album%;%year%
$loopend()

would write %albumartist%;%album%;%year% + linebreak for every new %album%. So it would skip all files with the same %album% value after writing the values of the first file.


Thanks, I now have it working

eg

FLAC tag genre like this:

R&B\\Soundtrack\\Rock

Replaced %genre% with $meta_sep(genre,\\) in csv export script

now xls import of resultant csv has

R&B\\Soundtrack\\Rock
in genre column

Perfect cool.gif

Thanks again for your help, Mark
m4rk
QUOTE (pone @ Feb 22 2012, 12:29) *
yes, in the export help section http://help.mp3tag.de/options_export.html#syntax :



So if you have something like
CODE
$loop(%_filename_ext%)%title%;%artist%;%album%;
$loopend()

the loop writes %title%;%artist%;%album%; + linebreak for every new %_filename_ext%.


Whereas this loop
CODE
$loop(%album%)%albumartist%;%album%;%year%
$loopend()

would write %albumartist%;%album%;%year% + linebreak for every new %album%. So it would skip all files with the same %album% value after writing the values of the first file.


Again very useful info. I was having to use Excel Office 2007 and the 'remove duplicates' function to create a simple list of albums and their genres.
m4rk
QUOTE (m4rk @ Feb 22 2012, 12:51) *
Again very useful info. I was having to use Excel Office 2007 and the 'remove duplicates' function to create a simple list of albums and their genres.



Maybe I am pushing my luck too far today...

$filename(csv,utf-16)|Album|Genre|
$loop(%album%)|%album%|$meta_sep(genre,\\)|
$loopend()

I was hoping this would produce a single line per album but its giving all tracks for the same album!!
pone
ZITAT(m4rk @ Feb 22 2012, 13:17) *
Maybe I am pushing my luck too far today...

$filename(csv,utf-16)|Album|Genre|
$loop(%album%)|%album%|$meta_sep(genre,\\)|
$loopend()

I was hoping this would produce a single line per album but its giving all tracks for the same album!!


Looks like I forgot something in my examples.

$loop(%album%) only sorts your files by %album%
$loop(%album%,1) sorts your files by %album% and does only write one entrie per %album%.

So try this:

$filename(csv,utf-16)|Album|Genre|
$loop(%album%,1)|%album%|$meta_sep(genre,\\)|
$loopend()
m4rk
QUOTE (pone @ Feb 22 2012, 13:40) *
Looks like I forgot something in my examples.

$loop(%album%) only sorts your files by %album%
$loop(%album%,1) sorts your files by %album% and does only write one entrie per %album%.

So try this:

$filename(csv,utf-16)|Album|Genre|
$loop(%album%,1)|%album%|$meta_sep(genre,\\)|
$loopend()


yup, that was it. I learnt a lot quickly today thanks to your suggestions. Thanks, much appreciated cool.gif
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.