Skip to content

Commit edbc9cb

Browse files
committed
add overwrite flag
1 parent 212a3ec commit edbc9cb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

mimic-iv/buildmimic/sqlite/import.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def main():
6767
'--data_dir', type=str, default='.',
6868
help='Path to the directory containing the MIMIC-IV CSV files.'
6969
)
70+
argparser.add_argument(
71+
'--overwrite', action='store_true',
72+
help='Overwrite existing mimic4.db file.'
73+
)
7074
args = argparser.parse_args()
7175

7276
# validate that we can find all the files
@@ -107,9 +111,12 @@ def main():
107111
print(f'Limiting to {len(subjects)} subjects.')
108112

109113
if os.path.exists(DATABASE_NAME):
110-
msg = "File {} already exists.".format(DATABASE_NAME)
111-
print(msg)
112-
sys.exit()
114+
if args.overwrite:
115+
os.remove(DATABASE_NAME)
116+
else:
117+
msg = "File {} already exists.".format(DATABASE_NAME)
118+
print(msg)
119+
sys.exit()
113120

114121
# For a subset of columns, we specify the data types to ensure
115122
# pandas loads the data correctly.

0 commit comments

Comments
 (0)