def loadCasting(catalog, file_casting): dialect = csv.excel() dialect.delimiter = ";" with open(cf.data_dir + file_casting, encoding="utf-8") as csvfile: row = csv.DictReader(csvfile, dialect=dialect) for casting in row: model.addActors(catalog, casting) model.addDirector(catalog, casting) model.addDirectorId(catalog, casting)
def loadDirector(catalog, directorfile): dialect, dialect.delimiter = csv.excel, ';' input_file = csv.DictReader(open(directorfile, encoding='utf-8-sig'), dialect=dialect) for dire in input_file: strip_dire = {} for key, value in dire.items(): strip_dire[key.strip()] = value.strip() dire = strip_dire model.addDirector(catalog, dire) directors_names = dire['director_name'].split(',') for directors in directors_names: if directors != 'none': model.addDirectorMovie(catalog, directors.lower(), dire)
def loadCasting(catalog, fileC, sep=';'): t1_start = process_time() # tiempo inicial dialect = csv.excel() dialect.delimiter = sep with open(fileC, encoding="utf-8-sig") as csvfile: input_file = csv.DictReader(csvfile, dialect=dialect) for movie in input_file: model.addCast(catalog, movie) director = movie['director_name'] if director == 'none': pass else: model.addDirector(catalog, movie) actor1 = movie['actor1_name'] if actor1 == 'none': pass else: model.addActor(catalog, movie, 1) actor2 = movie['actor2_name'] if actor2 == 'none': pass else: model.addActor(catalog, movie, 2) actor3 = movie['actor3_name'] if actor3 == 'none': pass else: model.addActor(catalog, movie, 3) actor4 = movie['actor4_name'] if actor4 == 'none': pass else: model.addActor(catalog, movie, 4) actor5 = movie['actor5_name'] if actor5 == 'none': pass else: model.addActor(catalog, movie, 5) t1_stop = process_time() # tiempo final print("Tiempo de ejecución ", t1_stop - t1_start, " segundos")
def loadMoviesCasting(catalog, file): dialect = csv.excel() dialect.delimiter = ";" with open(file, encoding="utf-8") as csvfile: row = csv.DictReader(csvfile, dialect=dialect) for elemento in row: model.addMovieCasting(catalog, elemento) name = elemento["id"] model.addMovieIdCasting(catalog, name, elemento) director = elemento["director_name"] movieDirectorId = elemento["id"] model.addDirector(catalog, director, movieDirectorId) actor1 = elemento["actor1_name"] actor2 = elemento["actor2_name"] actor3 = elemento["actor3_name"] actor4 = elemento["actor4_name"] actor5 = elemento["actor5_name"] movieActorId = elemento["id"] model.addActor(catalog, actor1, movieActorId) model.addActor(catalog, actor2, movieActorId) model.addActor(catalog, actor3, movieActorId) model.addActor(catalog, actor4, movieActorId) model.addActor(catalog, actor5, movieActorId)
def infoDirector(catalog, director): retorno = model.addDirector(catalog, director) return retorno