Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tweets_analyzer.py to add friends to json output #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tweets_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
id_screen_names = {}
friends_timezone = collections.Counter()
friends_lang = collections.Counter()
friends_list = collections.Counter()

def process_tweet(tweet):
""" Processing a single Tweet and updating our datasets """
Expand Down Expand Up @@ -196,6 +197,7 @@ def process_tweet(tweet):
def process_friend(friend):
""" Process a single friend """
friends_lang[friend.lang] += 1 # Getting friend language & timezone
friends_list[friend.screen_name] += 1 # Getting friend language & timezone
if friend.time_zone:
friends_timezone[friend.time_zone] += 1

Expand Down Expand Up @@ -457,6 +459,7 @@ def main():
cprint("[+] Friends timezones")
print_stats(friends_timezone, top=8)
jsono["top_friend_timezones"] = friends_timezone
jsono["friends"] = friends_list

if args.json is not False:
print(json.dumps(jsono))
Expand Down