@@ -44,7 +44,7 @@ for table_path in demographics/icustay_times;
4444do
4545 table=` echo $table_path | rev | cut -d/ -f1 | rev`
4646 echo " Generating ${TARGET_DATASET} .${table} "
47- bq query ${BQ_OPTIONS} --destination_table=${TARGET_DATASET} .${table} < ${table_path} .sql
47+ bq query ${BQ_OPTIONS} --destination_table=" ${TARGET_DATASET} .${table} " < " ${table_path} .sql"
4848done
4949
5050# generate tables in subfolders
5454# * organfailure depends on measurement
5555for d in demographics comorbidity measurement medication organfailure treatment firstday score sepsis;
5656do
57- for fn in ` ls $d ` ;
57+ for fn_path in " $d " / * .sql ;
5858 do
59- # only run SQL queries
60- if [[ " ${fn : -4} " == " .sql " ]] ; then
61- # table name is file name minus extension
62- tbl=` echo $fn | rev | cut -d. -f2- | rev `
59+ [ -f " $fn_path " ] || continue
60+ fn= $( basename " $fn_path " )
61+ # table name is file name minus extension
62+ tbl=" ${fn % .sql} "
6363
64- # skip certain tables where order matters
65- skip=0
66- for skip_table in meld icustay_times first_day_sofa kdigo_stages vasoactive_agent norepinephrine_equivalent_dose sepsis3
67- do
68- if [[ " ${tbl} " == " ${skip_table} " ]]; then
69- skip=1
70- break
71- fi
72- done ;
73- if [[ " ${skip} " == " 1" ]]; then
74- continue
75- fi
76-
77- # not skipping - so generate the table on bigquery
78- echo " Generating ${TARGET_DATASET} .${tbl} "
79- bq query ${BQ_OPTIONS} --destination_table=${TARGET_DATASET} .${tbl} < ${d} /${fn}
64+ # skip certain tables where order matters
65+ skip=0
66+ for skip_table in meld icustay_times first_day_sofa kdigo_stages vasoactive_agent norepinephrine_equivalent_dose sepsis3
67+ do
68+ if [[ " ${tbl} " == " ${skip_table} " ]]; then
69+ skip=1
70+ break
71+ fi
72+ done ;
73+ if [[ " ${skip} " == " 1" ]]; then
74+ continue
8075 fi
76+
77+ # not skipping - so generate the table on bigquery
78+ echo " Generating ${TARGET_DATASET} .${tbl} "
79+ bq query ${BQ_OPTIONS} --destination_table=" ${TARGET_DATASET} .${tbl} " < " ${fn_path} "
8180 done
8281done
8382
8887 table=` echo $table_path | rev | cut -d/ -f1 | rev`
8988
9089 echo " Generating ${TARGET_DATASET} .${table} "
91- bq query ${BQ_OPTIONS} --destination_table=${TARGET_DATASET} .${table} < ${table_path} .sql
90+ bq query ${BQ_OPTIONS} --destination_table=" ${TARGET_DATASET} .${table} " < " ${table_path} .sql"
9291done
0 commit comments