Skip to content

read_fwf() function does not infer compression by default #22199

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

Closed
NasaGeek opened this issue Aug 5, 2018 · 0 comments · Fixed by #22200
Closed

read_fwf() function does not infer compression by default #22199

NasaGeek opened this issue Aug 5, 2018 · 0 comments · Fixed by #22200
Labels
Bug Compat pandas objects compatability with Numpy or Python functions IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@NasaGeek
Copy link
Contributor

NasaGeek commented Aug 5, 2018

Code Sample, a copy-pastable example if possible

import io
import gzip
import os
import pandas as pd

fwf = b"""a b c\n1 2 3\n4 5 6"""
with gzip.open('file.gz', 'wb') as gz:
    gz.write(fwf)
print(pd.read_fwf('file.gz', compression='infer'))
print(pd.read_fwf('file.gz'))
os.remove('file.gz')

Problem description

The pandas documentation indicates that read_fwf() (as with read_csv()) infers a file's compression type based on its extension by default, but it does not.

Expected Output

I expect 2 identical copies of the dataframe to be displayed.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: 776fed3
python: 3.7.0.final.0
python-bits: 64
OS: Darwin
OS-release: 17.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.0.dev0+418.g776fed3ab
pytest: 3.7.1
pip: 10.0.1
setuptools: 39.0.1
Cython: 0.28.5
numpy: 1.15.0
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: 1.7.6
patsy: None
dateutil: 2.7.3
pytz: 2018.5
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: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
None

@WillAyd WillAyd added the IO Data IO issues that don't fit into a more specific label label Aug 6, 2018
@WillAyd WillAyd added this to the Contributions Welcome milestone Aug 6, 2018
@gfyoung gfyoung removed this from the Contributions Welcome milestone Dec 19, 2018
@gfyoung gfyoung added the Bug label Dec 19, 2018
gfyoung pushed a commit to NasaGeek/pandas that referenced this issue Dec 19, 2018
@gfyoung gfyoung added the Compat pandas objects compatability with Numpy or Python functions label Dec 19, 2018
gfyoung pushed a commit to NasaGeek/pandas that referenced this issue Dec 24, 2018
@jreback jreback added this to the 0.24.0 milestone Dec 24, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants