Skip to content

TypeError with pd.read_sas() (pandas 0.18.0) #12647

Closed
@raderaj

Description

Code Sample, a copy-pastable example if possible

df = pd.read_sas('infilename.sas7bdat')

Expected Output

to read a sas7bdat file into a pandas data frame.

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.0
setuptools: 20.2.2
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.3
sphinx: 1.3.5
patsy: 0.4.0
dateutil: 2.5.0
pytz: 2016.1
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.6
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
jinja2: 2.8

boto: 2.39.0

Error seen

TypeError Traceback (most recent call last)
in ()
----> 1 pd.read_sas('mydatainfo.sas7bdat')

C:\Anaconda\lib\site-packages\pandas\io\sas\sasreader.py in read_sas(filepath_or_buffer, format, index, encoding, chunksize, iterator)
52 reader = SAS7BDATReader(filepath_or_buffer, index=index,
53 encoding=encoding,
---> 54 chunksize=chunksize)
55 else:
56 raise ValueError('unknown SAS format')

C:\Anaconda\lib\site-packages\pandas\io\sas\sas7bdat.py in init(self, path_or_buf, index, convert_dates, blank_missing, chunksize, encoding)
234 self._path_or_buf = open(self._path_or_buf, 'rb')
235
--> 236 self._get_properties()
237 self._parse_metadata()
238

C:\Anaconda\lib\site-packages\pandas\io\sas\sas7bdat.py in _get_properties(self)
333 self.os_name = buf.rstrip(b'\x00 ').decode()
334 else:
--> 335 buf = self._path_or_buf.read(_os_maker_offset, _os_maker_length)
336 self.os_name = buf.rstrip(b'\x00 ').decode()
337

TypeError: read() takes at most 1 argument (2 given)


Tracking down the error:

It looks like line 335 should either be set up to read a single length from the _path_or_buf bytestream something like:
buf = self._path_or_buf.read(_os_maker_length)
or replace it with something like this
buf = self._read_bytes(_os_maker_offset, _os_maker_length)


** note i tried this under python3.5 and got the same error.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions