The Comma-Separated Values (CSV) format is probably the simplest way to store tabular data in a text file. In this recipe, we will create a management command that imports data from a CSV file to a Django database. We will need a CSV list of songs. You can easily create such a file with Excel, Calc, or another spreadsheet application.
Importing data from a local CSV file
Getting ready
Let's create a music app that we'll be using throughout this chapter:
- Create the music app itself and put it under INSTALLED_APPS in the settings:
# myproject/settings/_base.py
INSTALLED_APPS = [
# …
"myproject.apps.core",
"myproject.apps.music",
]
- The Song model there should contain the uuid, artist...