Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
first commit
- Loading branch information
0 parents
commit 379b37d
Showing
8 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data/facebook_auth.csv | ||
data/facebook_auth_ingmar.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Assimilation | ||
A study of immigrant assimilation using both Facebook advertising data and a traditional survey. | ||
|
||
## Install | ||
Running the code requires installing packages with `conda`. | ||
|
||
`conda install -r requirements.txt` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Data | ||
This directory contains input and output data. | ||
|
||
- facebook_auth.csv | ||
Contains access token and user ID. Necessary for mining FB data. | ||
- newyork_expats.json | ||
Contains JSON configuration for sample query (expats living in New York). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ACCESS_TOKEN,USER_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ "name": "Expats Distribution in New York", | ||
"geo_locations": [ | ||
{ | ||
"name": "cities", | ||
"values": [{"key":"2490299"}], | ||
"location_types": ["home"] | ||
} | ||
], | ||
"behavior": [ | ||
{"or" : [6019673233983], "name" : "Expats (Zimbabwe)"}, | ||
{"or" : [6027149006383], "name" : "Expats (Vietnam)"}, | ||
{"or" : [6026404871583], "name" : "Expats (Venezuela)"}, | ||
{"or" : [6023620475783], "name" : "Expats (US)"}, | ||
{"or" : [6019396649183], "name" : "Expats (United States)"}, | ||
{"or" : [6021354152983], "name" : "Expats (UK)"}, | ||
{"or" : [6019673501783], "name" : "Expats (Uganda)"}, | ||
{"or" : [6023516430783], "name" : "Expats (UAE)"}, | ||
{"or" : [6019366994183], "name" : "Expats (Turkey)"} | ||
], | ||
"ages_ranges": [ | ||
{"min":18} | ||
], | ||
"genders": [0] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tabulate==0.7.7 | ||
codecov==2.0.5 | ||
numpy==1.11.1 | ||
coloredlogs==5.2 | ||
coverage==4.2 | ||
cython==0.27.3 | ||
pandas==0.19.0 | ||
pytest_cov==2.4.0 | ||
requests==2.11.1 | ||
setuptools==28.2.0 | ||
git+https://github.com/maraujo/pySocialWatcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Scripts | ||
These are the scripts necessary for collecting and analysing the data. | ||
|
||
- data_processing/ | ||
Mine and clean data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from argparse import ArgumentParser | ||
from pysocialwatcher import watcherAPI | ||
import os | ||
|
||
def main(): | ||
parser = ArgumentParser() | ||
parser.add_argument('--auth_file', default='data/facebook_auth_ingmar.csv') | ||
parser.add_argument('--query_file', default='data/newyork_expats.json') | ||
parser.add_argument('--out_dir', default='data/') | ||
args = parser.parse_args() | ||
auth_file = args.auth_file | ||
query_file = args.query_file | ||
out_dir = args.out_dir | ||
|
||
## set up watcher | ||
watcher = watcherAPI() | ||
watcher.load_credentials_file(auth_file) | ||
watcher.check_tokens_account_valid() | ||
|
||
## test query | ||
output = watcher.run_data_collection(query_file) | ||
|
||
## write to file | ||
if(not os.path.exists(out_dir)): | ||
os.mkdir(out_dir) | ||
out_base = os.path.basename(query_file).replace('.json', '.tsv') | ||
out_file = os.path.join(out_dir, out_base) | ||
output.to_csv(out_file, sep='\t') | ||
|
||
if __name__ == '__main__': | ||
main() |