Skip to content

Commit 8d8f251

Browse files
authored
Merge pull request #1355 from cmu-delphi/roll-up-raceeth-microdata
[survey] Add race-ethnicity microdata support to monthly rollup script
2 parents 0b7103a + 622e950 commit 8d8f251

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

facebook/micro/monthly-archive.sh

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ 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 [email protected] 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 [email protected]
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 [email protected]
11+
12+
perform_rollup_and_post ()
13+
{
14+
BATCH="cd $1\nls -1 cvid_responses_${MONTH}*.gz"
15+
sftp -b <(echo -e "${BATCH}") -P 2222 [email protected] 2>/dev/null | \
16+
grep "^cvid" | \
17+
awk -F_ -vDIR="$1" 'BEGIN{print "cd " DIR} {key=$3 $4 $5; if (key!=last && last!="") {print record} last=key; record=$0} END{print record}' | \
18+
sed '/^cvid/ s/^/get /' >fetch.sftp
19+
sftp -b fetch.sftp -P 2222 [email protected]
20+
OUT=${MONTH/_/-}
21+
Rscript ../monthly-files.R ${MONTH%_*} ${R_MONTH} . >${OUT}.csv
22+
gzip ${OUT}.csv
23+
sftp -b <(echo -e "cd $1\nput ${OUT}.csv.gz") -P 2222 [email protected]
24+
rm -rf $1
25+
mkdir $1
26+
mv *.gz $1/
27+
}
28+
29+
perform_rollup_and_post "fb-public-results"
30+
perform_rollup_and_post "protected-race-ethnicity-data"

0 commit comments

Comments
 (0)