-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Clarified error in read_sas method when buffer object provided withou… #14947
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
Changes from 4 commits
b52f204
f8166fc
5efdb85
bf60d23
aa1ada3
ffdce1d
ab76d80
4cf9231
1285dbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,11 @@ def read_sas(filepath_or_buffer, format=None, index=None, encoding=None, | |
DataFrame if iterator=False and chunksize=None, else SAS7BDATReader | ||
or XportReader | ||
""" | ||
|
||
from pandas import compat | ||
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. import should be at the top of the file (if might be there already) |
||
if format is None: | ||
buffErr = "Format unrecognized. If buffer object, specify format" | ||
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. use buffer_error_msg. If this is a buffer object, rather than a string name, you must specify a format string. |
||
if not isinstance(filepath_or_buffer,compat.string_types): | ||
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. You have some PEP8 errors (we check for them in the travis build, that is the reason travis failed). For example, here there should be a space after the comma. Here is the full list (you can find it at the bottom of the failing test (third travis build), but I also recommend setting up your IDE to check for this):
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. I think I got this covered. I'll reread the Pandas submission info for how to ensure PEP8 compliance tonight. |
||
raise TypeError(buffErr) | ||
try: | ||
fname = filepath_or_buffer.lower() | ||
if fname.endswith(".xpt"): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pandas.util.testing as tm | ||
|
||
class TestSasBuff(tm.TestCase): | ||
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. You can call this just 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. Done. |
||
def test_sas_buffer_format(self): | ||
import StringIO | ||
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. imports go at the top |
||
from pandas.io.sas.sasreader import read_sas | ||
b = StringIO.StringIO("") | ||
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. from pandas import read_sas 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. from pandas.compat import StringIO |
||
with self.assertRaises(TypeError): | ||
read_sas(b) |
Uh oh!
There was an error while loading. Please reload this page.
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.
Bug when reading a buffer object in
pd.read_sas()
, without a specified format, a filepath string was inferred rather than buffer object.move to Bug Fix section, add the issue number (this PR) at the end