-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Throw a ParserError when header rows have unequal column counts … #43118
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
53a1768
BUG: Throw a ParserError when header rows have unequal column counts …
quantumalaviya 128b4e3
BUG: Throw a ParserError when header rows have unequal column counts.…
quantumalaviya 6483df7
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya bec4d00
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya 95bac98
Added Test. (GH43102)
quantumalaviya 10422a8
Added Test. (GH43102)
quantumalaviya 658c291
Added Test. (GH43102)
quantumalaviya a02d476
Added Changes. (GH43102)
quantumalaviya 87bf9a2
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya f1b1a89
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya fb963d8
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya 5f534ea
Added whatsnew
quantumalaviya 5239ece
Added whatsnew
quantumalaviya 0dbc0cc
Merge remote-tracking branch 'upstream/master' into b43102
quantumalaviya 863e996
Test without whatsnew
quantumalaviya 532e6cb
Add whatsnew again
quantumalaviya 2533bd1
Merge branch 'master' into b43102
quantumalaviya 7d01f0a
Merged upstream
quantumalaviya 1caf42d
Update v1.4.0.rst
quantumalaviya 921b57d
Merged upstream
quantumalaviya 2ca6ccf
Merge upstream
quantumalaviya 3f1fb39
Skipping test on PyArrow
quantumalaviya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,3 +585,20 @@ def test_read_csv_multiindex_columns(all_parsers): | |
tm.assert_frame_equal(df1, expected.iloc[:1]) | ||
df2 = parser.read_csv(StringIO(s2), header=[0, 1]) | ||
tm.assert_frame_equal(df2, expected) | ||
|
||
|
||
def test_read_csv_multi_header_length_check(all_parsers): | ||
# GH#43102 | ||
parser = all_parsers | ||
|
||
case = """row11,row12,row13 | ||
row21,row22, row23 | ||
row31,row32 | ||
""" | ||
|
||
with pytest.raises( | ||
ParserError, | ||
match="Header rows must have equal number of columns. " | ||
"Mismatch found at header 1.", | ||
): | ||
parser.read_csv(StringIO(case), sep=",", header=[0, 2]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sep is the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, I will get rid of it, thanks |
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.
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.
You could do this like
all(len(x) == len(ls[0]) for x in ls[1:])
has the downside that the element where the error was found is not clear
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.
So you do suggest removing that part of the error? It can simply say "Header rows must have an equal number of columns."
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.
Yeah I would go with that.