Skip to content

Commit 181841a

Browse files
committed
fix to target physionet-data
1 parent 97c7be5 commit 181841a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mimic-iv/concepts/copy_concepts_to_versioned_schema.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ if [ -z "$$1" ]; then
66
fi
77
export SOURCE_DATASET=mimiciv_derived
88
export TARGET_DATASET=mimiciv_$1_derived
9+
export PROJECT_ID=physionet-data
910

1011
# check if the target dataset exists
11-
if bq ls | grep -q ${TARGET_DATASET}; then
12+
if bq ls --datasets --project_id ${PROJECT_ID} | grep -q ${TARGET_DATASET}; then
1213
echo "Using existing dataset ${TARGET_DATASET}."
1314
# drop the existing tables in the target dataset
1415
# this includes ones which may not be in the source dataset
15-
for TABLE in `bq ls physionet-data:${TARGET_DATASET} | cut -d' ' -f3`;
16+
for TABLE in `bq ls ${PROJECT_ID}:${TARGET_DATASET} | cut -d' ' -f3`;
1617
do
1718
# skip the first line of dashes
1819
if [[ "${TABLE:0:2}" == '--' ]]; then
1920
continue
2021
fi
21-
echo "Dropping table ${TARGET_DATASET}.${TABLE}"
22-
bq rm -f -q ${TARGET_DATASET}.${TABLE}
22+
bq rm -f -q ${PROJECT_ID}:${TARGET_DATASET}.${TABLE}
2323
done
2424
else
25-
echo "Creating dataset ${TARGET_DATASET}"
26-
bq mk --dataset ${TARGET_DATASET}
25+
echo "Creating dataset ${PROJECT_ID}:${TARGET_DATASET}"
26+
bq mk --dataset ${PROJECT_ID}:${TARGET_DATASET}
2727
fi
2828

29-
for TABLE in `bq ls physionet-data:${SOURCE_DATASET} | cut -d' ' -f3`;
29+
echo "Copying tables from ${SOURCE_DATASET} to ${TARGET_DATASET}."
30+
for TABLE in `bq ls ${PROJECT_ID}:${SOURCE_DATASET} | cut -d' ' -f3`;
3031
do
3132
# skip the first line of dashes
3233
if [[ "${TABLE:0:2}" == '--' ]]; then
3334
continue
3435
fi
35-
echo "${SOURCE_DATASET}.${TABLE} -> ${TARGET_DATASET}.${TABLE}"
36-
bq cp -f -q ${SOURCE_DATASET}.${TABLE} ${TARGET_DATASET}.${TABLE}
36+
bq cp -f -q ${PROJECT_ID}:${SOURCE_DATASET}.${TABLE} ${PROJECT_ID}:${TARGET_DATASET}.${TABLE}
3737
done

0 commit comments

Comments
 (0)