-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a fix for issue #196 #197
Conversation
Do you mind adding a file with the blank line and a new test for it to avoid regressions? |
Sure thing. Shouldn't take me long |
I undid my fix and ran the unit test first. If there's a blank line in the header of the file the ctd.read_btl() function crashes when checking the metadata["names"].index("Date"). rowtypes = df[df.columns[-1]].unique()
# Get times and dates which occur on second line of each bottle.
######## Crash happens here because _parse_seabird() quits before setting names ######
date_idx = metadata["names"].index("Date")
############################################################################
dates = df.iloc[:: len(rowtypes), date_idx].reset_index(drop=True)
times = df.iloc[1 :: len(rowtypes), date_idx].reset_index(drop=True)
datetimes = dates + " " + times With the fix all existing unit tests pass along with the new one |
Sorry I don't know what this 'add-trailing-comma' issue is in the pre-commit.ci check |
I'm going to scrap this PR and resubmit. I foolishly forgot how forking a repo works. I didn't realize I was pulling main from my forked version which was way behind the authoritative version. |
I hope you'll consider this fix for issue #196
The read._parse_sea_bird() function will break out of the loop reading lines if a blank line is encountered. This is a simple fix that checks if the line is empty, then will move to the next line without breaking out of the loop. This maintains the proper 'skiprows' to find the data header lines containing the names of the columns and seems to also pass existing unit tests.