A script to parse Facebook's personal data export and generate a few descriptive charts.
Facebook's data export consists of a dozen JSON files in different folders based on what type of activity they track. The format for each is similar - an object with one key, which has a list of objects with information about the activity.
Activity Grapher's first step is to open each of these JSON files, get the list of activities, and map them to a common set of keys. These are yield to a parent function, which inserts them into a SQLite database. SQLite is just used as an intermediary - the event log could easily be written to a CSV, or probably kept in memory, but having a simple database makes adding charts easier.
Next, a few cleanup scripts are run - converting timestamps to dates, guessing when removed friends may have first been added, and mapping friends into groups.
Finally, we use matplotlib to create a handful of explanatory graphs:
- Timeline of actions by month
- % of actions that are Likes by month
- Balance of posts on your wall vs. posts on friends walls
- Total friends over time
- Total friends over time by group (provided during mapping)
To get your data from Facebook, follow these steps:
- On Facebook go to Settings
- Click on Your Facebook Information, then Download Your Information
- Click Create File. Facebook will let you know when it's ready, then you can download and unzip.
Download fb_parse.py and fb_sql.py, and move them into the unzipped Facebook data folder. In the command line, run fb_parse.py and follow the prompts.
This was written in Python 3.6, with numpy and matplotlib (>=2.0).