IPB

Welcome Guest ( Log In | Register )

> Notice!

Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.

Also make sure you've read the Forum Guidelines before posting in this forum.

 
Reply to this topicStart new topic
> List of tracks for each album (CSV)
pabloluih
post May 16 2017, 01:48
Post #1


Member


Group: Members
Posts: 2
Joined: 16-May 17
Member No.: 23427
Mp3tag Version: 2.82



Hello, I am not an expert with syntax of CSV, I have been reading about it but I cannot reach my objetive.
I want to export a CSV with 1 line=1 album=a list of all its tracks. Because of the csv format limitation I do not know how to add all tracks in 1 same line.
At this time I tried with this, but it print 1 line for each track:

QUOTE
$filename(csv,utf-8) "artist","album","year","tracks","trackcount"
$loop(%album%)$loop(%track%) "%artist%","%album%","%year%","%track%. %title% ( %_length% )","%_total%"
$loopend()$loopend()


I want to accomplish something like this, noticing that there are 2 different albums with their corresponding metadata in order to export it to another database:

QUOTE
Title,"Artist","Year","Country","Format","Cover","Barcode","Label","My rating","Youtube","Genres","Styles","Tracks","Track count"
Michael,"Michael Jackson","2010","CD","","","","Epic","","0","Pop, Electronic, Funk / Soul","","1. Hold My Hand ( 03:33 )
2. Hollywood Tonight ( 04:31 )
3. Keep Your Head Up ( 04:51 )
4. (I Like) The Way You Love Me ( 04:34 )
5. Monster ( 05:06 )
6. Best of Joy ( 03:03 )
7. Breaking News ( 04:14 )
8. (I Can't Make It) Another Day ( 03:55 )
9. Behind the Mask ( 05:02 )
10. Much Too Soon ( 02:48 )","10"
2300 Jackson Street,"The Jackson 5","1989","Vinyl","","","","Epic","","0","","","1. Art of Madness ( 05:07 )
2. Nothin' (That Compares 2 U) ( 05:22 )
3. Maria ( 05:49 )
4. Private Affair ( 04:10 )
5. 2300 Jackson Street ( 05:06 )
6. Harley ( 04:24 )
7. She ( 05:01 )
8. Alright With Me ( 03:25 )
9. Play It Up ( 04:53 )
10. Midnight Rendezvous ( 04:24 )
11. If You'd Only Believe ( 06:14 )","11"


I hope I made myself clear. Thanks in advance.

This post has been edited by pabloluih: May 16 2017, 01:49
Go to the top of the page
 
+Quote Post
ryerman
post May 16 2017, 04:37
Post #2


Member


Group: Full Members
Posts: 242
Joined: 16-August 09
From: Canada
Member No.: 10731
Mp3tag Version: 2.85



Make use of the $get and $puts functions.
http://help.mp3tag.de/main_scripting.html#variable

Try this:
CODE
$filename($getEnv(USERPROFILE)\Desktop\Albums.csv,utf-8)"artist","album","year","tracks","trackcount"
$loop(%album%)
$loop(%track%)
$puts(TRACKS,$get(TRACKS)',' %track%. %title% ( %_length% ))$puts(TRACKCOUNT,$add($get(TRACKCOUNT),1))
$loopend()
"%artist%"','"%album%"','"%year%"','"$trim($get(TRACKS),', ')"','"$get(TRACKCOUNT)"
$puts(TRACKS,)$puts(TRACKCOUNT,0)
$loopend()

The result has lots of blank lines but these can be removed with Notepad++ or online with Text Mechanic (http://textmechanic.com)


--------------------
Windows 10 Home, 64 bit
Go to the top of the page
 
+Quote Post
ohrenkino
post May 16 2017, 06:29
Post #3


Member


Group: Full Members
Posts: 9237
Joined: 9-December 09
From: Norddeutschland / Northern Germany
Member No.: 11458
Mp3tag Version: 2.85



ZITAT(pabloluih @ May 16 2017, 02:48) *
...I want to export a CSV with 1 line=1 album=a list of all its tracks.... to export it to another database:

Just a question: does it really make sense to get all track titles and the album into one line?
CSV works like a table without the lines. where each column has one specific header.
So if you have further data following the last TITLE then this data will end up in various columns, depending on the number of TITLES. In your example one album had 10, the other one 11 TITLEs.
So the finishing "trackcount" can then be found once in column 11 and the next time in column 12.

To cut things short: you have a classical 1:n relation where n is a real variable that varies.
To get a proper database, you would have to design a record (=one line) with all the data that identifies a single TITLE without hicups. This could be the unique combination of ARTIST, ALBUM, TRACK and TITLE.
Grouping tracks together so that they show up as one album, is a problem of the database front-end.
The export should create a unique data set.


--------------------
42 - wie war die Frage / what was the question / quelle était la question
Go to the top of the page
 
+Quote Post
pabloluih
post May 16 2017, 14:49
Post #4


Member


Group: Members
Posts: 2
Joined: 16-May 17
Member No.: 23427
Mp3tag Version: 2.82



QUOTE (ryerman @ May 16 2017, 05:37) *
Make use of the $get and $puts functions.
http://help.mp3tag.de/main_scripting.html#variable

Try this:
CODE
$filename($getEnv(USERPROFILE)\Desktop\Albums.csv,utf-8)"artist","album","year","tracks","trackcount"
$loop(%album%)
$loop(%track%)
$puts(TRACKS,$get(TRACKS)',' %track%. %title% ( %_length% ))$puts(TRACKCOUNT,$add($get(TRACKCOUNT),1))
$loopend()
"%artist%"','"%album%"','"%year%"','"$trim($get(TRACKS),', ')"','"$get(TRACKCOUNT)"
$puts(TRACKS,)$puts(TRACKCOUNT,0)
$loopend()

The result has lots of blank lines but these can be removed with Notepad++ or online with Text Mechanic (http://textmechanic.com)


Thank you! Is much more than I could have done! The only problem is that it seems that the database that I am using sets the tracklist as independent lines for each track. But it is not a problem as it is plain text.

QUOTE (ohrenkino @ May 16 2017, 07:29) *
Just a question: does it really make sense to get all track titles and the album into one line?
CSV works like a table without the lines. where each column has one specific header.
So if you have further data following the last TITLE then this data will end up in various columns, depending on the number of TITLES. In your example one album had 10, the other one 11 TITLEs.
So the finishing "trackcount" can then be found once in column 11 and the next time in column 12.

To cut things short: you have a classical 1:n relation where n is a real variable that varies.
To get a proper database, you would have to design a record (=one line) with all the data that identifies a single TITLE without hicups. This could be the unique combination of ARTIST, ALBUM, TRACK and TITLE.
Grouping tracks together so that they show up as one album, is a problem of the database front-end.
The export should create a unique data set.


I know, that was what I planned at first but when I saw the structure of the database... The app I am using is Memento Database for Android. I wanted to have all media grouped in one single app, but I am facing the problem that with music it only admits the creation of an album catalog, so you can not add tracks 'one by one' to be grouped into album and consequently related to an artist. I do not know how to explain properly, here is what it allows you to do: http://imgur.com/a/DTxC3

So you see that in 'Tracks' it only admits a list of plain text. That's why I needed this request. The solution that provides @ryerman fits perfectly, but it does not separate each track into multiple lines but with a comma.

Thank you all!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd November 2017 - 11:54