djay playlists: CSV to M3U

Some people asked me how I convert djay csv files to a more univerally compatible m3u playlist, so I decided to post my solution here.

The Bad News:
This solution, is not end-user friendly. It’s written in Python, so you have to know, or be willing to learn, how to run the code. I created this in macOS, it should work in Windows. I’m not sure about iOS.

The Good News:
It works. You can quickly produce m3u playlists that are easy to backup and import into other software (like iTunes, Serato, Rekordbox, Virtual DJ, Traktor, MP3Tag etc.).

How It Works:
Give the program a .csv file from djay and it will create an .m3u playlist file. For example:

  • export a djay playlist as hip-hop.csv
  • the code will create an m3u playlist called hip-hop.m3u, that can be dragged directly into iTunes, Serato etc… FYI - double-clicking a .m3u file on a Mac will automatically load it into iTunes.

STEPS TO RUN THE CODE:

  1. Install Python:
    https://www.python.org

  2. Copy/Paste the code into a plain-text file. Give the file a .py extension. For example, createplaylist.py note: I over-documented the code, so you can see what every line does.

# python modules
import os # command line utilities
import csv # file utilties
import urllib.parse # decode URL to File Path
from tkinter import filedialog # graphical interface

# Main Function Definition
def createM3U():
    # Set Files and Directories
    csvFile = filedialog.askopenfilename() # ask user for csv file
    m3uFile = csvFile.rstrip(".csv") + ".m3u" # m3u playlist name
    dirName = os.path.dirname(csvFile) # set export directory

    # Transfer Playlist Data
    with open(csvFile, 'r') as file: # open csv file
        csvData = csv.reader(file, delimiter=',') # get csv data
        with open(m3uFile, 'w') as file: # create m3u file
            header = next(csvData) # skip header row   
            for row in csvData: # for each audio track
                # decode URL
                audioTrack = "/" + urllib.parse.unquote(row[6].lstrip('file://')) + "\n"
                file.write(audioTrack) # add track to m3u playlist

    # Show Files to User (only tested on Mac)
    os.system('open ' + dirName)

# Run Main Function
createM3U()
  1. Running The Code
  • Command Line Terminal
    python createplaylist.py
    or python3 createplaylist.py

  • Python Launcher (GUI)
    right-click on the Python file, select Open With > Python Launcher
    pythonlauncher

  • VS Code (IDE)
    For those who are savvy, you can run the python code in an IDE like VS Code.

1 Like

DJ SET HISTORY
if you just need to export your historical DJ Sets, there is a command in djay Pro that will transfer the DJ Set playlists directly to iTunes (where you can export it as a .m3u file)

Screenshot 2023-08-09 at 10.39.11 AM

Custom Playlists in djay Collection
Unfortunately, for custom playlists in the djay Collection, you have to use the python code in the 1st post…

Nice work on this @Michael_Wisniewski! Thanks for the detailed explanation as well.

1 Like

Wow wow wow! Amazeballs in Awesomesauce!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.