You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
801 B

from django.core.management.base import BaseCommand, CommandError
from lyrics.models import Album, Artista, Song
import csv
import argparse
from datetime import datetime
class Command(BaseCommand):
help = "Importa la lista de letras"
def add_arguments(self, parser):
parser.add_argument("fichero_csv", type=str, help='Ruta al fichero csv')
def handle(self, *args, **options):
fichero = options["fichero_csv"]
with open(fichero, 'r') as file:
reader = csv.DictReader(file)
for row in reader:
title = row['title'],
artist = row['artist'],
album = row['album'],
year = row['year'],
lyrics = row['lyrics']
pista = row['pista']
print(title, ",", artist, ",", album, ",", year, ",", pista)