Skip to content
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

Closed
wants to merge 7 commits into from
Closed

Added a fix for issue #196 #197

wants to merge 7 commits into from

Conversation

upsonp
Copy link
Contributor

@upsonp upsonp commented Nov 29, 2023

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.

@ocefpaf
Copy link
Member

ocefpaf commented Dec 4, 2023

Do you mind adding a file with the blank line and a new test for it to avoid regressions?

@upsonp
Copy link
Contributor Author

upsonp commented Dec 4, 2023

Sure thing. Shouldn't take me long

@upsonp
Copy link
Contributor Author

upsonp commented Dec 4, 2023

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

@upsonp
Copy link
Contributor Author

upsonp commented Dec 4, 2023

Sorry I don't know what this 'add-trailing-comma' issue is in the pre-commit.ci check

@upsonp
Copy link
Contributor Author

upsonp commented Dec 6, 2023

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.

@upsonp upsonp closed this Dec 6, 2023
@upsonp upsonp deleted the DFO_issues branch December 6, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants