I am interested in downloading yearly data from some location on the internet.
I have a python script GetYearData.py which does this, taking as a command-line argument the year and the output filename.
I'd like to run this script on several years of data at once; I want to use Make so that if I change the start or end year I don't have to re-download all the data.
I can do this for a single year with a very simple Makefile:
data/YearData_2000.txt : GetYearData.py
python $< --year 2000 --outfile $@
However, I'd like to do this a loop (or similar construction) so that, for each year in a sequence in bash I'd say YEARS=($(seq $(SYEAR) 1 $(EYEAR))) -- I pass --year $(Y) to my script and generate an appropriate target for --outfile?
Try something like:
SYEAR = 2000
EYEAR = 2017
YEARS := $(shell seq $(SYEAR) 1 $(EYEAR))
all: $(patsubst %,data/YearData_%.txt,$(YEARS))
data/YearData_%.txt : GetYearData.py
python $< --year $* --outfile $@
You can override SYEAR and EYEAR on the make command line if you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With