def populate_database(imdb_file) : """this function builds a actor database""" try : # There is an empty string in the database which causes an IndexError imdb.process_file(imdb_file, store_actor_movie_record) except IndexError, e: print "imdb.process_file threw a string index error %s. Giving up on %s and continuing" % \ ( e, imdb_file )
def populate_database(imdb_file): """this function builds a actor database""" try: # There is an empty string in the database which causes an IndexError imdb.process_file(imdb_file, store_actor_movie_record) except IndexError, e: print "imdb.process_file threw a string index error %s. Giving up on %s and continuing" % \ ( e, imdb_file )
for movie, actorList in moviesActors.iteritems(): coStarsDB = shelve.open(newFileName) for actor in actorList: actorIndex = actorList.index(actor) movieCoStars = actorList movieCoStars.remove(actor) if coStarsDB.has_key(actor): # attempt to add all movieCoStars to actors costarts in coStarsDB currentCostarList = coStarsDB[actor] for costar in movieCoStars: if costar not in currentCostarList: currentCostarList.append(costar) coStarsDB[actor] = currentCostarList else: coStarsDB[actor] = movieCoStars actorList.insert(actorIndex, actor) coStarsDB.close() moviesActors.close() def shelf_print(fileName): print "in shelf_print" d = shelve.open(fileName) for k,v in d.iteritems(): print k, v d.close() # imdb.process_file('actors.list.gz', shelf_info) imdb.process_file('actresses.list.gz', shelf_write, 10000) find_costars('actorMovies') shelf_print('costars') # def process_file(filename, f, num=float('Inf')):
def db_film_actor(actor, date, title, role): act_act = defaultdict(list) for i in all_genders: act_act[i[2]].append(i[0]) return act_act # return { actor: [actor2, actor56]} def db_actor_actor(actor, date, title, role): ''' act_act = defaultdict(list) for i in all_genders: act_act[i[2]].append(i[0]) ''' pass all_genders = [] def from_x_to_kevin(actor): pass # return tuple [x_actor -> other_actor -> .... -> kevin] if __name__ == '__main__': print imdb.process_file('actors.list.gz', db_actor_film)
# return { actor : [list, of, his, films] } def db_film_actor(actor, date, title, role): act_act = defaultdict(list) for i in all_genders: act_act[i[2]].append(i[0]) return act_act # return { actor: [actor2, actor56]} def db_actor_actor(actor, date, title, role): ''' act_act = defaultdict(list) for i in all_genders: act_act[i[2]].append(i[0]) ''' pass all_genders = [] def from_x_to_kevin(actor): pass # return tuple [x_actor -> other_actor -> .... -> kevin] if __name__ == '__main__': print imdb.process_file('actors.list.gz', db_actor_film)