-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Python Parser skipping over items if BOM present in first element of header #36365
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look. Can you also add a whatsnew note for 1.2?
pandas/io/parsers.py
Outdated
@@ -2876,7 +2876,7 @@ def _check_for_bom(self, first_row): | |||
return [new_row] + first_row[1:] | |||
|
|||
elif len(first_row_bom) > 1: | |||
return [first_row_bom[1:]] | |||
return [first_row_bom[1:]] + first_row[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I don't find this very clear why we would do this - can you try refactoring the code above this to better suit the requirement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what I understand
the code block above removes the BOM from the first element of the row and removes the quotes if it was a quoted string. i.e. if it was of the format <BOM><QUOTE>abc<QUOTE>def
then it extracts out abcdef
I've tried to refactor it slightly
@@ -2127,6 +2127,12 @@ def test_first_row_bom(all_parsers): | |||
expected = DataFrame(columns=["Head1", "Head2", "Head3"]) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
# see gh-36343 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make this a new test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, I think test failures are unrelated. https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=42772&view=ms.vss-test-web.build-test-results-tab&runId=2173848&resultId=150762&paneView=debug
@gfyoung if you'd have a look |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm when green
thanks @asishm |
k thanks @asishm yeah there might be some others but IIRC those are for the c-parser |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff