def loadMovies(catalog, moviesfile, castingfile): """ Carga cada una de las lineas del archivo de movies. - Se agrega cada movie al catalogo de movies - Por cada movie se encuentran sus autores y por cada autor, se crea una lista con sus movies """ moviesfile = cf.data_dir + moviesfile input_file = csv.DictReader(open(moviesfile, encoding="utf-8-sig"), delimiter=";", quotechar='\"') castingfile = cf.data_dir + castingfile input_file2 = csv.DictReader(open(castingfile, encoding="utf-8-sig"), delimiter=";") for movie, casting in zip(input_file, input_file2): model.addMovies(catalog, movie) producers = movie['production_companies'].split( ";") # Se obtienen los autores model.addCasting(catalog, casting) directors = casting['director_name'] actors = [ casting['actor1_name'], casting['actor2_name'], casting['actor3_name'], casting['actor4_name'], casting['actor5_name'] ] genres = movie['genres'].split("|") countries = movie["production_countries"] for productor in producers: model.addMovieProducer(catalog, productor, movie) model.addMovieDirector(catalog, directors, movie) for actor in actors: model.addMovieActor(catalog, actor, movie, directors) for genre in genres: model.addMoviegenre(catalog, genre, movie) model.addMoviecountrie(catalog, countries, movie, directors)
def loadData(catalog, detailsfile, castingfile): """ Carga cada una de las lineas del archivo de libros. - Se agrega cada libro al catalogo de libros - Por cada libro se encuentran sus autores y por cada autor, se crea una lista con sus libros """ t1_start = process_time() #tiempo inicial dialect = csv.excel() dialect.delimiter = ";" detailsfile = cf.data_dir + detailsfile #input_file = #csv.DictReader(open(detailsfile,encoding="utf-8"), dialect=dialect) input_file = csv.DictReader(open(detailsfile, encoding="utf-8-sig"), dialect=dialect) castingfile = cf.data_dir + castingfile input_file2 = csv.DictReader(open(castingfile, encoding="utf-8"), dialect=dialect) #i = 0 #j = 0 for movie, casting in zip(input_file, input_file2): #i += 1 model.addMovie(catalog, movie) model.addCasting(catalog, casting, movie) #print(i) t1_stop = process_time() #print(t1_stop) """for casting in input_file2: j += 1 model.addCasting(catalog,casting) print(j) t1_stop = process_time() #tiempo final""" print("Tiempo de ejecución ", t1_stop - t1_start, " segundos")
def loadMovie2(catalog, moviesfile2): moviesfile2 = cf.data_dir + moviesfile2 dialect = csv.excel() dialect.delimiter = ";" input_file = csv.DictReader(open(moviesfile2, encoding="utf-8"), dialect=dialect) for movie in input_file: model.addCasting(catalog, movie)
def loadCastings(catalog, Moviesfile): dialect = csv.excel() dialect.delimiter = ";" try: with open(Moviesfile, encoding="utf-8") as csvfile: spamreader = csv.DictReader(csvfile, dialect=dialect) for row in spamreader: model.addCasting(catalog, row) authors = row['director_name'] # Se obtienen los autores model.addDirectorMovie(catalog, authors, row) for i in range(1, 6): author_name = "actor{}_name".format(i) model.addActorMovie(catalog, row[author_name], row) name_id = row['id'] model.addIdCastingMovie(catalog, name_id, row) except: print("Hubo un error con la carga del archivo") return 0
def loadmoviesCasting(catalog, castingfile): castingfile = cf.data_dir + castingfile dialect = csv.excel() dialect.delimiter = ";" input_file = csv.DictReader(open(castingfile, encoding='utf-8-sig'), dialect=dialect) for movie in input_file: model.addCasting(catalog, movie) if (movie['actor1_name'] != "none"): model.addMovieByActor(catalog, movie['actor1_name'], movie) if (movie['actor2_name'] != "none"): model.addMovieByActor(catalog, movie['actor2_name'], movie) if (movie['actor3_name'] != "none"): model.addMovieByActor(catalog, movie['actor3_name'], movie) if (movie['actor4_name'] != "none"): model.addMovieByActor(catalog, movie['actor4_name'], movie) if (movie['actor5_name'] != "none"): model.addMovieByActor(catalog, movie['actor5_name'], movie) model.addMovieByDirector(catalog, movie['director_name'], movie)