Skip to content

Instantly share code, notes, and snippets.

@JohnnyonFlame
JohnnyonFlame / json_to_csv.py
Last active November 11, 2021 22:37
Converts the Twitter API json to a CSV file using Pandas DataFrames
import json
import pandas as pd
from pandas.io.json import json_normalize
with open('todojsontweet.json', 'r') as f:
js = json.load(f)
df = json_normalize(data=js, meta=[])
# Transform hashtag entities into a flat list
def jsfilter(fi):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gdsaxton
gdsaxton / Social_Metrics_Tutorial_Script_User_Timeline_All_Pages.py
Created September 25, 2017 17:21
Downloading Tweets by a List of Users -- SQLite Version
#!/usr/bin/env python
"""
Social_Metrics_Tutorial_Script_User_Timeline_All_Pages.py - DOWNLOADS ALL AVAILABLE RECENT
TWEETS FROM 5 MLB ACCOUNTS INTO SQLITE DATABASE
BEFORE RUNNING THIS SCRIPT, YOU WILL NEED TO:
1. HAVE ANACONDA PYTHON 2.7 INSTALLED
2. HAVE CREATED CSV FILE (E.G., IN EXCEL) CONTAINING TWITTER HANDLES YOU
@macloo
macloo / twitter_bio_compiler_for_list.py
Last active October 20, 2022 22:27
Scrape members from a Twitter list and then get their bios, locations, etc.
#!/usr/bin/env python
# encoding: utf-8
"""
python 2.x
Scrape members from a Twitter list and then get their bios, locations, etc.
Based on
https://github.com/lamthuyvo/social-media-data-scripts/blob/master/scripts/twitter_bio_info_compiler.py
and
https://github.com/kylemanna/social-utils/blob/master/twitter/list-follow.py
@dannguyen
dannguyen / congress-twitter-data-getter.md
Last active August 21, 2022 07:57
Who Congress Follows on Twitter data

Find out who Congress follows on Twitter using the command line

Part of a lesson for the Stanford Journalism Computational Methods in the Civic Sphere

This is a short tutorial on how to use command-line tools, including csvfix and t, the command-line Twitter interface, to access and parse data from the Sunlight Foundation and Twitter. The end goal of this exercise is to gather who everyone in Congress follows (friends, in the parlance of Twitter), and then count up the common friends to find out which Twitter accounts are most followed by members of Congress.

Here's a screenshot of the result, after it's been imported into [Google Spreadsheets](https://docs.google.com/spreadsheets/d/1cjRJyrPYj8KAhUrot8ubPOWgbAwm0OqIgPtsswJ2sjM/edit#gid=1358907576