From edbc9cbda896fe9fe5562159a3d174451ef818c9 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Sat, 17 Aug 2024 08:45:24 -0400 Subject: [PATCH] add overwrite flag --- mimic-iv/buildmimic/sqlite/import.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mimic-iv/buildmimic/sqlite/import.py b/mimic-iv/buildmimic/sqlite/import.py index 33095c26..f99abd21 100644 --- a/mimic-iv/buildmimic/sqlite/import.py +++ b/mimic-iv/buildmimic/sqlite/import.py @@ -67,6 +67,10 @@ def main(): '--data_dir', type=str, default='.', help='Path to the directory containing the MIMIC-IV CSV files.' ) + argparser.add_argument( + '--overwrite', action='store_true', + help='Overwrite existing mimic4.db file.' + ) args = argparser.parse_args() # validate that we can find all the files @@ -107,9 +111,12 @@ def main(): print(f'Limiting to {len(subjects)} subjects.') if os.path.exists(DATABASE_NAME): - msg = "File {} already exists.".format(DATABASE_NAME) - print(msg) - sys.exit() + if args.overwrite: + os.remove(DATABASE_NAME) + else: + msg = "File {} already exists.".format(DATABASE_NAME) + print(msg) + sys.exit() # For a subset of columns, we specify the data types to ensure # pandas loads the data correctly.