|
|
@@ -1,26 +0,0 @@
|
|
|
-from django.core.management.base import BaseCommand, CommandError
|
|
|
-from lyrics.models import Album, Artista, Song
|
|
|
-import csv
|
|
|
-import argparse
|
|
|
-from datetime import datetime
|
|
|
-import pandas as pd
|
|
|
-
|
|
|
-
|
|
|
-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"]
|
|
|
- contenido = pd.read_csv(fichero)
|
|
|
-
|
|
|
- for fila in contenido.iterrows():
|
|
|
- print(fila[1].title, ", ", fila[1].artist, ", ", fila[1].album)
|
|
|
-
|
|
|
- artista = Artista.objects.get(nombre=fila[1].artist)
|
|
|
- album = Album.objects.get(pk=fila[1].album)
|
|
|
-
|
|
|
- cancion = Song(title=fila[1].title, artist=artista, album=album, pista=fila[1].pista, lyrics=fila[1].lyrics)
|
|
|
- cancion.save()
|