Skip to content

Instantly share code, notes, and snippets.

@juanitobanca
Last active November 8, 2020 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanitobanca/4f1e3ed2727264ef19ebcd1c05702772 to your computer and use it in GitHub Desktop.
Save juanitobanca/4f1e3ed2727264ef19ebcd1c05702772 to your computer and use it in GitHub Desktop.
#! /bin/bash
# Temporadas
from_season=${1}
to_season=${2}
# Constantes para descargar y procesar archivos de Rtrosheet
retrosheet_url="https://www.retrosheet.org/events/"
season_type_files="eve post"
# Para cada season
for s in $(seq ${from_season} ${to_season})
do
echo "Procesando temporada ${s}"
# Para cada season type
for t in ${season_type_files}
do
echo -e "\tProcesando ${t}"
echo -e "\t\tDescargando archivos"
wget ${retrosheet_url}${s}${t}.zip &> /dev/null
echo -e "\t\tDescomprimiendo archivos"
unzip ${s}${t}.zip &> /dev/null
echo -e "\t\tEjecutando Chadwick para Eventos"
cwevent -q -n -f 0-96 -x 0-60 -y ${s} ${s}*EV* > ${s}_${t}_events.csv 2> /dev/null
echo -e "\t\tEjecutando Chadwick para Partidos"
cwgame -q -n -f 0-83 -x 0-94 -y ${s} ${s}*EV* > ${s}_${t}_games.csv 2> /dev/null
echo -e "\t\tEjecutando Chadwick para Sustituciones"
cwsub -q -n -f 0-9 -y ${s} ${s}*EV* > ${s}_${t}_subs.csv 2> /dev/null
echo -e "\t\tLimpiando Archivos"
rm *EV*
rm *ROS*
rm *TEAM*
rm *.zip
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment