Skip to content

Commit

Permalink
add overwrite flag
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairewj committed Aug 17, 2024
1 parent 212a3ec commit edbc9cb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mimic-iv/buildmimic/sqlite/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit edbc9cb

Please sign in to comment.