-
Notifications
You must be signed in to change notification settings - Fork 0
/
liars-zip.fish
executable file
·44 lines (30 loc) · 1.12 KB
/
liars-zip.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env fish
set DIR liars
mkdir -p $DIR
function col -a line n
echo $line | awk -F ',' "{ print \$$n } "
end
set HEADERS (head -n 1 liars.csv)
tail -n +2 liars.csv | while read -l line
set -l bbl (col $line 1)
set -l job (col $line 2)
set -l address (echo (col $line 8) | tr ' ' '_' | tr -d '"')
set -l folder "$DIR/$job-$address"
echo $folder
mkdir -p $folder
mkdir -p $folder/dof
mkdir -p $folder/dob
# save csv row as json
printf "$HEADERS\n$line" | csvjson | jq '.' > $folder/jobinfo.json
# extract dates of rent stabilized tax bills
set bbl_json_file ~/.nyc-data/bbl/$bbl/$bbl.json
# copy rent stabilized tax files
cat $bbl_json_file | jq '.dof.taxBills | map(select(.rentStabilized)) | .[] | .date' | tr -d '"' \
| xargs -I DATE date --date='DATE' +'%B*%Y*.pdf' \
| xargs -I QUERY find ~/.nyc-data/dof/$bbl -type f -name 'QUERY' \
| xargs -I FILE cp FILE $folder/dof
# copy department of buildings pdfs and other files
find ~/.nyc-data/dob/$job -type f | xargs -I FILE cp FILE $folder/dob
end
# zip it all up
zip -r liars.zip liars/