Skip to content

BUG: python 3 compression and read_fwf #3963

@TomAugspurger

Description

@TomAugspurger

Getting a TypeError: Type str doesn't support the buffer API when using read_fwf on a compressed file with python 3 only; works in python 2.7

Example:

with a file fwf.bug.txt like

1111111111
2222222222
3333333333
4444444444

import pandas as pd

print(pd.__version__)

widths = [5, 5]

!gzip -d fwf_bug.txt

df = pd.read_fwf('fwf_bug.txt', widths=widths, names=['one', 'two'])
print(df)

!gzip fwf_bug.txt

# python 3 throws an error here.
df2 = pd.read_fwf('fwf_bug.txt.gz', widths=widths,
                  names=['one', 'two'], compression='gzip')

print(df2)

Versions:
python3: 0.11.1.dev-4d06037 should be most recent
python2: 0.11.1.dev-3ebfef9

I can paste the full traceback if you'd like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO CSVread_csv, to_csvIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions