Skip to content

Conversation

@lithomas1
Copy link
Contributor

@lithomas1 lithomas1 commented Jul 22, 2021

Precursor for pyarrow csv reader integration.

@jorisvandenbossche Do you know if there is any workaround I can use to read StringIO's on the arrow side? Adding this wrapper feels very hacky.

@lithomas1 lithomas1 requested a review from twoertwein July 26, 2021 15:43
@jreback jreback added Enhancement IO Data IO issues that don't fit into a more specific label Refactor Internal refactoring of code labels Jul 28, 2021
@lithomas1 lithomas1 requested review from jreback and twoertwein July 28, 2021 17:13

# Wrapper that wraps a StringIO buffer and reads bytes from it
# Created for compat with pyarrow read_csv
class BytesIOWrapper(io.BytesIO):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what pandas's policy is on public/private classes. Maybe name the class _BytesIOWrapper. @jreback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, this entire module is de-facto private.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we already expose TextIOWrapper so this is similar

@lithomas1 lithomas1 added this to the 1.4 milestone Aug 3, 2021
@lithomas1
Copy link
Contributor Author

gentle ping @jreback @jorisvandenbossche this is blocking integration of the pyarrow csv reader.


# Wrapper that wraps a StringIO buffer and reads bytes from it
# Created for compat with pyarrow read_csv
class BytesIOWrapper(io.BytesIO):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, this entire module is de-facto private.


# Wrapper that wraps a StringIO buffer and reads bytes from it
# Created for compat with pyarrow read_csv
class BytesIOWrapper(io.BytesIO):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we already expose TextIOWrapper so this is similar

@jreback jreback merged commit c5e236b into pandas-dev:master Aug 4, 2021
@jreback
Copy link
Contributor

jreback commented Aug 4, 2021

thanks @lithomas1 very nice! and thanks @twoertwein for reviewing

@lithomas1 lithomas1 deleted the bytesiowrapper branch August 9, 2021 17:06
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement IO Data IO issues that don't fit into a more specific label Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REF: in pandas.io.common integerate BytesIOWrapper into IOHandle

3 participants