Skip to content

Instantly share code, notes, and snippets.

@achavez
Created February 2, 2015 22:19
Show Gist options
  • Save achavez/69346bff5c08c24d1749 to your computer and use it in GitHub Desktop.
Save achavez/69346bff5c08c24d1749 to your computer and use it in GitHub Desktop.
Download all Texas expenditures from comptroller
#!/bin/bash
###########################################
# Download full year files and unzip them #
###########################################
year_files=(
"2009"
"2010"
"2011"
"2012"
"2013"
)
for i in "${year_files[@]}"
do
curl -L -o FY$i.zip http://www.texastransparency.org/Data_Center/files/EXP_FY_$i.zip
unzip FY$i.zip
done
mv "EXP_FY_2013" "EXP_FY_2013.txt"
###############################################################################
# Download FY 2014 & FY 2015 by separate months, because there's no year file #
###############################################################################
# FY 2014
files_2014=( "EXP_AUG_2014.txt"
"EXP_JUL_2014.txt"
"EXP_JUN_2014.txt"
"EXP_MAY_2014.txt"
"EXP_APR_2014.txt"
"EXP_MAR_2014.txt"
"EXP_FEB_2014.txt"
"EXP_JAN_2014.txt"
"EXP_DEC_2013.txt"
"EXP_NOV_2013.txt"
"EXP_OCT_2013.txt"
"EXP_SEP_2013.txt"
)
mkdir FY2014
for i in "${files_2014[@]}"
do
curl -L -o FY2014/$i http://www.texastransparency.org/Data_Center/files/$i
done
echo "Combining FY2014 files into FY2014.txt"
cat FY2014/*.txt > FY2014.txt
# FY 2015
files_2015=(
"EXP_DEC_2014.txt"
"EXP_NOV_2014.txt"
"EXP_OCT_2014.txt"
"EXP_SEP_2014.txt"
)
mkdir FY2015
for i in "${files_2015[@]}"
do
curl -L -o FY2015/$i http://www.texastransparency.org/Data_Center/files/$i
done
echo "Combining FY2015 files into FY2015.txt"
cat FY2015/*.txt > FY2015.txt
####################################
# Combine everything into one file #
####################################
echo "Combining all downloads into ALL_YEARS.txt"
cat *.txt > ALL_YEARS.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment