-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
read_json(lines=True) broken for s3 urls in Python 3 (v0.20.3) #17200
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
Comments
Well we do have a |
@gfyoung I'm not intimately familiar with the codebase, but I have a (possibly naive) fix that just attempts to decode the json based on whatever |
Don't worry, that's a pretty tall order 😄 Absolutely! Submit a PR, and we'll certainly review it. |
FYI, here's how we handle it on the CSV side: Line 401 in 3c833db
that |
Naive PR submitted ;) @gfyoung |
…andas-dev#17201) (cherry picked from commit 4fd104a)
workaround:
my data was gzipped - you prob don't need the decode... |
Code Sample, a copy-pastable example if possible
Using Python
The file is similar to:
Problem description
When attempting to read a python lines file into a DataFrame using the s3 protocol, the above code will error with:
This works fine if the file is local, e.g.:
Expected Output
Expect to successfully read the file and error above not to occur.
My current thinking is that when we get the file handle: https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/io/json/json.py#L333 , you delegate to
s3fs
, which documents that it only operates in Binary mode. Therefore when youread()
: https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/io/json/json.py#L335, Therefore passing toStringIO
will fail here: https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/io/json/json.py#L347 . Maybe it needs a different handler forBytesIO
?Output of
pd.show_versions()
pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.2.7
Cython: None
numpy: 1.12.0
scipy: 0.19.1
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: None
s3fs: 0.1.2
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: