-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
33 lines (27 loc) · 1.04 KB
/
Makefile
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
DATA_DIR=./data
.PHONY: clean
all: $(DATA_DIR)/proposicoes_votadas.csv $(DATA_DIR)/votacoes_proposicoes.json $(DATA_DIR)/proposicoes.csv
clean:
rm -rf $(DATA_DIR)
$(DATA_DIR)/proposicoes_votadas.csv:
mkdir -p $(DATA_DIR)
$(eval OUTFILE := $@)
rm -f $(OUTFILE) # scrapy doesn't support incrementally updating files
scrapy crawl proposicoes_votadas_em_plenario -L INFO -o $(OUTFILE)
# Sort the file
$(eval TMPFILE := $(shell mktemp -u))
head -1 $(OUTFILE) > $(TMPFILE)
sed -i -e "1d" $(OUTFILE)
sort -t, -k1 $(OUTFILE) >> $(TMPFILE)
mv $(TMPFILE) $(OUTFILE)
touch $(OUTFILE)
$(DATA_DIR)/votacoes_proposicoes.json: $(DATA_DIR)/proposicoes_votadas.csv
mkdir -p $(DATA_DIR)
$(eval OUTFILE := $@)
rm -f $(OUTFILE) # scrapy doesn't support incrementally updating files
scrapy crawl votacoes_proposicoes -L INFO -o $(OUTFILE)
$(DATA_DIR)/proposicoes.csv: $(DATA_DIR)/proposicoes_votadas.csv
mkdir -p $(DATA_DIR)
$(eval OUTFILE := $@)
rm -f $(OUTFILE) # scrapy doesn't support incrementally updating files
scrapy crawl proposicoes -L INFO -o $(OUTFILE)