Skip to content

Instantly share code, notes, and snippets.

@cquest
Created March 10, 2015 22:47
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 cquest/6320cd95da07010732ed to your computer and use it in GitHub Desktop.
Save cquest/6320cd95da07010732ed to your computer and use it in GitHub Desktop.
Exemple de script de download, conversion XLS vers CSV, reformattage et fusion en un unique CSV
curl 'https://www.data.gouv.fr/fr/datasets/donnees-d-execution-budgetaire-des-collectivites-territoriales-3/' -s | grep href.*xls -o | grep http.*xls -o | wget -i - --quiet
for f in *.xls; do in2csv $f | head -n 1 > $f.csv; done
for f in *.xls; do for s in `seq -w 01 19` 2A 2B `seq -w 21 95`; do in2csv --sheet "Departement_$s""_" $f | tail -n +2 >> $f.csv; done; done
for f in *.xls; do for s in 971 972 973 974 976; do in2csv --sheet "Departement_$s" $f | tail -n +2 >> $f.csv; done; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment