-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_raw_bot_data.py
35 lines (31 loc) · 1.06 KB
/
parse_raw_bot_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import io
import os
import re
import pprint
import random
import time
import hashlib
import base64
import sys
import datetime
data_dir = "top-100-bot-search/"
def get_data():
filename = data_dir + "raw-data-201706011805.txt"
output_string = "ID | Screen_name | created_at | following | followers | tweets | default_profile | default_profile_image | follows_trump\n"
bot_count = 0
trump_count = 0
if os.path.exists(filename):
with open(filename) as f:
lines = f.read().splitlines()
for line in lines:
twid, name, date, following, followers, tweets, def_profile, def_picture, follows_trump = line.split("|")
if "21" in following and "0" in tweets and "Yes" in def_profile and "Yes" in def_picture:
output_string += line + "\n"
bot_count += 1
if "Yes" in follows_trump:
trump_count += 1
print output_string
print "Found " + str(bot_count)
print "Found " + str(trump_count) + " trump followers"
if __name__ == '__main__':
get_data()