From b66eb3d909d4622e1073e1325afc7766d7f9ce7a Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Thu, 23 Apr 2020 21:42:00 +0530 Subject: [PATCH] Move csv files to different folder because Twint isn't saving to absolute path --- displayuserinfo.py | 2 ++ fetchcsv.py | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/displayuserinfo.py b/displayuserinfo.py index 17a3c66..f38d6da 100644 --- a/displayuserinfo.py +++ b/displayuserinfo.py @@ -1,4 +1,6 @@ from flask import Flask +import pandas + app = Flask(__name__) @app.route('/') diff --git a/fetchcsv.py b/fetchcsv.py index 4efe80d..0e851ae 100644 --- a/fetchcsv.py +++ b/fetchcsv.py @@ -5,15 +5,27 @@ import twint import os from usernames import * +import shutil +import os + +current_folder_path = os.path.abspath(os.getcwd()) def fetchUserdata(username): c = twint.Config() c.Username = username c.Limit = 10 c.Store_csv = True - current_folder_path = os.path.abspath(os.getcwd()) c.Output = os.path.join(current_folder_path, f"{username}.csv") twint.run.Search(c) for idx, username in enumerate(twitterUsernames): - fetchUserdata(username) \ No newline at end of file + fetchUserdata(username) + +# Twint saves all csv files in the same folder, so move all of them to usercsv/ +# todo: Find out why Twint doesn save to absolute path and remove the need for this step +files = os.listdir(current_folder_path) +destfolder = os.path.join(current_folder_path,'usercsv') +for f in files: + if (f.endswith('.csv')): + shutil.move(os.path.join(current_folder_path,f), os.path.join(destfolder,f)) +