Skip to content

Instantly share code, notes, and snippets.

@troyhill
Last active July 10, 2018 18:27
Show Gist options
  • Save troyhill/901aa4471ef8867bc5fffbfc5fd9da12 to your computer and use it in GitHub Desktop.
Save troyhill/901aa4471ef8867bc5fffbfc5fd9da12 to your computer and use it in GitHub Desktop.
DBHYDRO-DataForEver data transfer
#!/bin/bash
# Script downloads station or project-level water quality data from DBHYDRO and uploads it to DataForEver
# Projects are specified in a file argument sent to script
# Usage: ./bash/upload_project_data_20180425.sh ~/RDATA/dataForEver/station_lists/20180514_deering.lst station
# create date-stamped folder for downloaded data
if [ "$#" < 1 ]
then
echo "Usage: $0 target_list report_type" 1>&2
exit 1
fi
inputFile=$1
reportType=${2:-station}
time_stamp=$(date +%Y%m%d)
dir_name="/home/thill/RDATA/dbhydro/data/${time_stamp}"
if [ ! -d $dir_name ]; then
mkdir -p $dir_name
echo $dir_name
fi
# Pull data using R script (sending it the project code argument from the target_projects file)
while read line; do
echo "Target $reportType: $line, $dir_name"
./RDATA/dbhydro/dbhydro_functions_gist_20180425.R $line $dir_name $reportType
done < $inputFile
# upload project data to DataForEver
. set_project waterquality
for entry in $dir_name/*
do load_sfwmd_file waterquality load_sfwmd_file $entry y y
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment