fork download
  1. import sys, os
  2. import pandas as pd
  3.  
  4.  
  5. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "movierec.settings")
  6.  
  7.  
  8. import django
  9. django.setup()
  10.  
  11.  
  12. from movies.models import Movie
  13.  
  14.  
  15. def save_movie_from_row(movie_row):
  16. movie = Movie()
  17. movie.title = movie_row[1]
  18. movie.genres = movie_row[2]
  19. movie.save()
  20.  
  21.  
  22. if __name__ == "__main__":
  23.  
  24. if len(sys.argv) == 2:
  25. print("Reading from file {}".format(str(sys.argv[1])))
  26. movies_df = pd.read_csv(sys.argv[1])
  27. print(movies_df)
  28.  
  29. movies_df.apply(
  30. save_movie_from_row,
  31. axis=1
  32. )
  33.  
  34. print("There are {} reviews in DB".format(Movie.objects.count()))
  35. else:
  36. print("Please, provide Movie file path")
  37.  
Runtime error #stdin #stdout #stderr 0.02s 27704KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
ImportError: No module named 'pandas'