from threading import Thread q = Queue() fill_queue() while not q.empty(): print("Queue Size: ", q.qsize()) print("Number of positive comments: ", facebookDb.getPositiveCommentCount()) threads = [] for thread in range(100): t1 = Thread(target=run) t1.start() threads.append(t1) for thread in threads: thread.join() while not to_insert.empty(): data = to_insert.get() comment_count = data.comment_count post_id = data.post_id facebookDb.insertCommentCountData(comment_count, post_id) # posts = facebookDb.selectFacebookData() # tgc = ThreadCommentGetter() # tgc.run() import time print("Done", datetime.now())
import pandas as pd from Notebooks.LinkDatabases.FacebookData import FacebookDataDatabase from Notebooks.LinkDatabases.PostComments import PostDataDatabase facebookDb = FacebookDataDatabase() commentDb = PostDataDatabase() comment_data = commentDb.selectPostData() df = pd.DataFrame.from_records(comment_data, columns=["imageId", "commentId", "text"]) for imageId in df.imageId.unique(): count = len(df[df["imageId"] == imageId]) facebookDb.insertCommentCountData(count, imageId)