Skip to content

Commit 5fd9083

Browse files
committed
support monthly combining of raceeth microdata
1 parent 83ba3f9 commit 5fd9083

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

facebook/micro/monthly-archive.sh

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@ else
88
fi
99
echo ${MONTH}
1010
R_MONTH=${MONTH#*_}; R_MONTH=${R_MONTH#0}
11-
BATCH="cd fb-public-results\nls -1 cvid_responses_${MONTH}*.gz"
12-
sftp -b <(echo -e "${BATCH}") -P 2222 fb-automation@ftp.delphi.cmu.edu 2>/dev/null | \
13-
grep "^cvid" | \
14-
awk -F_ 'BEGIN{print "cd fb-public-results"} {key=$3 $4 $5; if (key!=last && last!="") {print record} last=key; record=$0} END{print record}' | \
15-
sed '/^cvid/ s/^/get /' >fetch.sftp
16-
sftp -b fetch.sftp -P 2222 fb-automation@ftp.delphi.cmu.edu
17-
OUT=${MONTH/_/-}
18-
Rscript ../monthly-files.R ${MONTH%_*} ${R_MONTH} . >${OUT}.csv
19-
gzip ${OUT}.csv
20-
sftp -b <(echo -e "cd fb-public-results\nput ${OUT}.csv.gz") -P 2222 fb-automation@ftp.delphi.cmu.edu
11+
12+
# Save script's arguments to reference by name in perform_rollup_and_post() so the script's
13+
# positional arguments and perform_rollup_and_post's positional arguments don't get confusing.
14+
arg0=$0
15+
arg3=$3
16+
arg4=$4
17+
arg5=$5
18+
19+
perform_rollup_and_post ()
20+
{
21+
BATCH="cd $1\nls -1 cvid_responses_${MONTH}*.gz"
22+
sftp -b <(echo -e "${BATCH}") -P 2222 fb-automation@ftp.delphi.cmu.edu 2>/dev/null | \
23+
grep "^cvid" | \
24+
awk -F_ 'BEGIN{print "cd $1"} {key=$arg3 $arg4 $arg5; if (key!=last && last!="") {print record} last=key; record=$arg0} END{print record}' | \
25+
sed '/^cvid/ s/^/get /' >fetch.sftp
26+
sftp -b fetch.sftp -P 2222 fb-automation@ftp.delphi.cmu.edu
27+
OUT=${MONTH/_/-}
28+
Rscript ../monthly-files.R ${MONTH%_*} ${R_MONTH} . >${OUT}.csv
29+
gzip ${OUT}.csv
30+
sftp -b <(echo -e "cd $1\nput ${OUT}.csv.gz") -P 2222 fb-automation@ftp.delphi.cmu.edu
31+
}
32+
33+
perform_rollup_and_post "fb-public-results"
34+
perform_rollup_and_post "protected-race-ethnicity-data"

0 commit comments

Comments
 (0)