Fix add_oracle_rowdelimiter output filename using str.strip instead of suffix removal#1995
Open
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Open
Fix add_oracle_rowdelimiter output filename using str.strip instead of suffix removal#1995Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
`mimic-iii/buildmimic/oracle/add_oracle_rowdelimiter.py` derives the output filename from the input with:
```python
fn_out = fn_in.strip('.csv') + '_output.csv'
```
`str.strip(chars)` treats its argument as a set of characters to remove from both ends, not a literal suffix. With `'.csv'` the set is `{'.', 'c', 's', 'v'}`, so any trailing run of those characters is eaten along with the extension. For the canonical MIMIC-III CSV filenames:
```python
So every input whose stem ends in one of `c`, `s`, or `v` silently loses those characters in the output filename. The row-delimited file then lands at a subtly renamed path, out of line with the input table name that downstream SQL\*Loader control files expect.
Root cause
Same `str.strip` vs suffix-removal misuse that PR #1989 fixed in `mimic-iii/buildmimic/sqlite/import.py`, applied here to the Oracle build path but missed by that fix.
Why the fix is correct
Replacing `fn_in.strip('.csv')` with `fn_in[:-len('.csv')]` removes exactly the `.csv` suffix (4 characters) and nothing else, so `patients.csv` → `patients_output.csv`, `icustays.csv` → `icustays_output.csv`, etc. This matches the pattern already adopted by `mimic-iii/buildmimic/sqlite/import.py` post-#1989 and is compatible with the Python 2-compatible style this script uses (it still imports `print_function` from `future`), so no `str.removesuffix` / Python 3.9+ dependency is introduced.