Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Convert your personal Facebook JSON archive to CSV or pandas dataframe for data analysis

NotificationsYou must be signed in to change notification settings

epogrebnyak/facebook-json-to-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert your personal Facebook JSON archive to CSV files or pandas dataframes.

How to use

  1. Request a JSON archive from Facebook, download it and unpack zip file to local folder.
  2. Copyfriends.py somewhere you can use it, for example
curl -o friends.py https://raw.githubusercontent.com/epogrebnyak/facebook-json-to-csv/master/friends.py
  1. Prey the Facebook JSON schema has not changed since I wrote this code(please fil an issue if it did).
  2. Try some code below.

Examples

Bulk conversion:

from friends import save_csv_allsave_csv_all(source_dir="./facebook-epogrebnyak",              output_dir="./output_folder")

creates the following files:

Saved files:  output_folder\friends.csv  output_folder\comments.csv  output_folder\posts.csv  output_folder\address_book.csv  output_folder\reactions.csv  output_folder\sessions.csv

Read your data with functions:

fromfriendsimportget_friends,get_address_book,get_postsdirectory="C:/temp/facebook-me"# your path to folder with JSON herefriends=get_friends(directory)phones=get_address_book(directory)posts=get_posts(directory)

More flexible reading - as dicts, dataframes, etc:

fromfriendsimportFriends,Comments,Posts,AddressBook,Reactions,Sessionf=Friends("./facebook-epogrebnyak")friends=f.get_tuples()# list of (timestamp, name) tuplesfriends_dicts=f.get_dicts()# same data as list of dictionariesfriends_gen=f.iterate()# generator, useful for streaming large archivesfriends_df=f.get_dataframe()# pandas DataFrame ready for analysisf.save_csv("./output_folder")# saves data to 'friends.csv'

See howfriends.py drawes some bars in the terminal:

Contacts from my phonebook stored by Facebook:Total: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 212Friends added by month (total 39)2020-01: ▇▇▇ 3    2020-02: ▇▇ 2    2020-03: ▇▇ 2    2020-04: ▇▇▇ 3    2020-05: ▇▇▇▇▇▇▇▇ 8    2020-06: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 18   2020-07: ▇▇▇ 3    Number of posts and comments by month (total 72)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 32   2020-02: ▇▇▇▇▇▇▇▇▇ 15   2020-03: ▇▇ 4    2020-04: ▇▇▇▇▇▇▇▇ 13   2020-05: ▇ 2    2020-06: ▏ 1    2020-07: ▇▇▇ 5    Reactions by month (total 289)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 102  2020-02: ▇▇▇▇▇▇▇▇▇▇▇▇▇ 67   2020-03: ▇▇▇▇▇ 27   2020-04: ▇▇▇▇ 22   2020-05: ▇▇▇▇ 22   2020-06: ▇▇ 13   2020-07: ▇▇▇▇▇▇▇ 36   Sessions by month (total 640)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 201  2020-02: ▇▇▇▇▇▇▇▇▇▇ 108  2020-03: ▇▇▇▇▇▇▇▇▇▇ 107  2020-04: ▇▇▇▇▇▇▇ 75   2020-05: ▇▇▇▇▇ 56   2020-06: ▇▇▇▇ 42   2020-07: ▇▇▇▇ 50   2020-08: ▏ 1    Session locations (includes VPN): Amsterdam, Balashikha, Bronnitsy, Elektrosal, Helsinki, Kashira, Kazan, Khimki, Kostroma, Moscow, Nizhny Novgorod, Nuremberg, Oryekhovo, Otvazhnoye, Penza, Samara, Sergiyevskoye, Serpukhov, Shchelkovo, Sofrino, Soligalich, Solnechnogorski, Tallinn, Tolyatti, Ufa, Zelënyy GorodSaved files:  output_folder\friends.csv  output_folder\comments.csv  output_folder\posts.csv  output_folder\address_book.csv  output_folder\reactions.csv  output_folder\sessions.csvrunfile('D:/github/facebook-json-to-csv/friends.py', wdir='D:/github/facebook-json-to-csv')Contacts from my phonebook stored by Facebook:Total: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 212Friends added by month (total 39)2020-01: ▇▇▇ 3    2020-02: ▇▇ 2    2020-03: ▇▇ 2    2020-04: ▇▇▇ 3    2020-05: ▇▇▇▇▇▇▇▇ 8    2020-06: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 18   2020-07: ▇▇▇ 3    Number of posts and comments by month (total 72)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 32   2020-02: ▇▇▇▇▇▇▇▇▇ 15   2020-03: ▇▇ 4    2020-04: ▇▇▇▇▇▇▇▇ 13   2020-05: ▇ 2    2020-06: ▏ 1    2020-07: ▇▇▇ 5    Reactions by month (total 289)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 102  2020-02: ▇▇▇▇▇▇▇▇▇▇▇▇▇ 67   2020-03: ▇▇▇▇▇ 27   2020-04: ▇▇▇▇ 22   2020-05: ▇▇▇▇ 22   2020-06: ▇▇ 13   2020-07: ▇▇▇▇▇▇▇ 36   Sessions by month (total 640)2020-01: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 201  2020-02: ▇▇▇▇▇▇▇▇▇▇ 108  2020-03: ▇▇▇▇▇▇▇▇▇▇ 107  2020-04: ▇▇▇▇▇▇▇ 75   2020-05: ▇▇▇▇▇ 56   2020-06: ▇▇▇▇ 42   2020-07: ▇▇▇▇ 50   2020-08: ▏ 1    Session locations (includes VPN): Amsterdam, Balashikha, Bronnitsy, Elektrosal, Helsinki, Kashira, Kazan, Khimki, Kostroma, Moscow, Nizhny Novgorod, Nuremberg, Oryekhovo, Otvazhnoye, Penza, Samara, Sergiyevskoye, Serpukhov, Shchelkovo, Sofrino, Soligalich, Solnechnogorski, Tallinn, Tolyatti, Ufa, Zelënyy GorodSaved files:  output_folder\friends.csv  output_folder\comments.csv  output_folder\posts.csv  output_folder\address_book.csv  output_folder\reactions.csv  output_folder\sessions.csv

Background

Motivated by desire for break free from FB without loosing the data.

Similar efforts:

About

Convert your personal Facebook JSON archive to CSV or pandas dataframe for data analysis

Topics

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp