Export query to CSV

Is there a way to export a query to CSV?
Currently I create a comma separated path that I copy from the terminal and import in Excel but since titles sometimes containg comma’s too that’s with mixed results.

I’ve read throught the plugins but couldn’t find anything that could do it.

It wouldn’t escape things correctly, but you could use -f;

beet ls -f '$title,$albumartist,$album'

Thanks @jackwilsdon I’ve been using something similar.
Is there a way to add tabs in the path? So that I can import it as a tab delimited file instead of comma?

And do I understand from your reply that there isn’t a way to export to CSV directly?

You can add tabs using printf;

beet ls -f "$(printf '$title\t$albumartist\t$album')"

It isn’t “true” CSV so to speak, as it doesn’t properly escape things such as quotes within the fields. Using tab delimiters probably negates this issue pretty well, as it’s unlikely any of your songs have tabs in their title, album artist or album name.

Ah but this is already a big step in the right direction, better than comma’s. Thanks!

1 Like