-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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 5 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
""" | ||
Read SAS sas7bdat or xport files. | ||
""" | ||
|
||
from pandas import compat | ||
|
||
def read_sas(filepath_or_buffer, format=None, index=None, encoding=None, | ||
chunksize=None, iterator=False): | ||
|
@@ -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 | ||
""" | ||
|
||
if format is None: | ||
buffer_error_msg = "If this is a buffer object rather\ | ||
than a string name, you must specify a format string" | ||
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. Can you use
instead of |
||
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(buffer_error_msg) | ||
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 | ||
from pandas.compat import StringIO | ||
from pandas import read_sas | ||
|
||
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): | ||
b = StringIO("") | ||
with self.assertRaises(TypeError): | ||
read_sas(b) |
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