-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: improves message raised for bad names in usecols (GH14154) #14163
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
Current coverage is 85.24% (diff: 53.84%)@@ master #14163 diff @@
==========================================
Files 139 139
Lines 50502 50502
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 43055 43051 -4
- Misses 7447 7451 +4
Partials 0 0
|
raise ValueError("Usecols do not match names.") | ||
bad_cols = [n for n in self.usecols if n not in self.names] | ||
if len(bad_cols) > 0: | ||
raise ValueError(("%s specified in usecols but not found " |
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.
use .format()
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 prob also need a ','.join(bad_cols)
, need a test for this
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.
@jreback I'm trying to get the following test to work:
msg = ("c, d specified in usecols but not found in names.")
with tm.assertRaisesRegexp(ValueError, msg):
self.read_csv(StringIO(data), names=['a', 'b'], usecols=['c', 'd'], header=None)
Currently this test fails because two exceptions are being raised: one by parsers.py
, which produces the expected message; and one by parser.pyx
, which produces a different message. But, when I try to play with this in my interpreter, I only get the first, expected, ValueError
message. Where does the parser.pyx
exception get raised to? Is it necessary?
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.
it's possible we need to put this checking earlier
@aechase Do you have time to update this? |
@jorisvandenbossche I'll take another look at it next week. I discovered that this error message gets raised in several (redundant) places, which made it a more complex issue than I originally had time for. |
we just updated some usecols functionaility, so if you could rebase would be great. |
can you rebase |
@jreback I'm afraid I'm not going to have time to look at this for at least a couple of weeks. |
closing as stale. please ping if you'd like to continue. |
git diff upstream/master | flake8 --diff