Author Topic: xmplibdump: Python script to dump an XMPlay library to CSV format  (Read 621 times)

Gerf

  • Posts: 2
Hi everyone; long-time XMPlay fan, first-time poster.

I'd been looking for a utility to dump the contents of an XMPlay library file to CSV for easy import into a spreadsheet/database, and while there's this tool that can dump the data into XML (which could then be CSV-ified later), I kind of wanted to cut out the XML middleman and just do it all in one step. So I wrote xmplibdump, a small Python 3 script that will do just that with a command such as:

Code: [Select]
$ python xmplibdump.py xmplay.library > library.csv
Source and download here: https://github.com/gerf/xmplibdump

It's not particularly optimized or thoroughly tested, but it did what I wanted it to do and I hope someone else can get value out of it as well. If you run into a bug or unexpected output, feel free to let me know. Cheers!

saga

  • Posts: 2720
Nice tool! I also wrote some library processing code over ten years ago, so here's some tips:
The library version only ever gets increased if there is a change in the binary format. Your tool just blindly takes any XMPlay library and assumes that it has the expected format. So you should reject any library version except for the ones that you explicitly support. Ignoring the library version is not forwards-compatible, because the tool will just read garbage once a library version 7 file is tried to be processed.
The lowest library version I have any information on is version 3, which includes all the information up to and including the song flags (except for "subsongs", see below).
Version 4 adds the rating, and version 5 adds the subsong count and subsong number.
I think the subsong field (after the file type) is the only addition in version 6, as that is missing in my old tool that only support version 3 to 5.
So, either your tool should reject and version number other than 6, or you could add support for versions 3 through 5 by reading the fields that I mentioned above conditionally. Hope that helps! :)
« Last Edit: 28 Mar '24 - 15:27 by saga »

Gerf

  • Posts: 2
Thanks for the tips! :D