def process(self,loaded_data,proyecto,geo=""): if isinstance(loaded_data, str): loaded_data=json.loads(loaded_data) try: count_json,count=freq_counter([loaded_data]) except Exception as e: if "expected string or buffer" in e: print "Contador de frequencias recibe un string: No se guardo el csv" else: count_json,count=freq_counter(loaded_data) try: #-----------------USER PROCESSING---------------------- lst_users=Dock.find_users(loaded_data) Dock.json_csv_xlwt(lst_users,"user",proyecto,csv_path) #user_info=[] # for item in loaded_data: # user_info.append(Dock.user_csv(item)) except twitter.TwitterError as e: print "solo se puede conseguir informacion de usuarios si se carga un json" graph=create_graph(loaded_data) Dock.json_csv_xlwt(loaded_data,"tweet",proyecto,csv_path) Dock.json_csv_xlwt(count_json,"freq_count",proyecto,csv_path) if geo != "": gexf_filename='search_results_'+proyecto+'_'+geo+'.gexf' save_to_gexf(graph,gexf_path+'/'+gexf_filename) else: gexf_filename='search_results_'+proyecto+'.gexf' save_to_gexf(graph,gexf_path+'/'+gexf_filename)
def post_processing(insta_results, unauthenticated_api,query): friends_graph=None friends_json=None #Dock.insta_json_csv(insta_results, type='likes') graph= create_likes_graph(insta_results) gexf_filename='search_results_'+query+'.gexf' save_to_gexf(graph,gexf_path+'/'+gexf_filename) for media in insta_results: if friends_graph: try: friends_graph,friends_json=friends_network(1,unauthenticated_api,media,friends_graph=friends_graph) except Exception as e: print e else: friends_graph,friends_json=friends_network(1,unauthenticated_api,media) gexf_filename='search_results_'+query+'_friends.gexf' save_to_gexf(graph,gexf_path+'/'+gexf_filename) return friends_json #Dock.insta_json_csv(friends_json, type='friends') # users, next=unauthenticated_api.user_followed_by(media.user.id) # print media.user.username +' followed by:' # for user in users: # print user.username # print '\n' # print 'done'