Skip to content

Commit 5c5b8b6

Browse files
fix: load plain .csv in mimic-iii sqlite import.py
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4cf9855 commit 5c5b8b6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎mimic-iii/buildmimic/sqlite/import.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ def _table_name_from_csv(filename: str) -> str:
2626
print(msg)
2727
sys.exit()
2828

29+
# Prefer .csv.gz when both exist for the same table; also load plain .csv
30+
# (import.sh already accepts both).
31+
files_by_table = {}
32+
for f in glob("*.csv"):
33+
files_by_table[_table_name_from_csv(f)] = f
2934
for f in glob("*.csv.gz"):
35+
files_by_table[_table_name_from_csv(f)] = f
36+
37+
for table, f in sorted(files_by_table.items()):
3038
print("Starting processing {}".format(f))
31-
table = _table_name_from_csv(f)
3239
if os.path.getsize(f) < THRESHOLD_SIZE:
3340
df = pd.read_csv(f, index_col="ROW_ID")
3441
df.to_sql(table, CONNECTION_STRING)

0 commit comments

Comments
 (0)