-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Add BytesIOWrapper #42669
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
ENH: Add BytesIOWrapper #42669
Conversation
@@ -878,6 +888,46 @@ def __next__(self) -> str: | |||
return newline.lstrip("\n") | |||
|
|||
|
|||
# Wrapper that wraps a StringIO buffer and reads bytes from it | |||
# Created for compat with pyarrow read_csv | |||
class BytesIOWrapper(io.BytesIO): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
gentle ping @jreback @jorisvandenbossche this is blocking integration of the pyarrow csv reader. |
@@ -878,6 +888,46 @@ def __next__(self) -> str: | |||
return newline.lstrip("\n") | |||
|
|||
|
|||
# Wrapper that wraps a StringIO buffer and reads bytes from it | |||
# Created for compat with pyarrow read_csv | |||
class BytesIOWrapper(io.BytesIO): |
There was a problem hiding this comment.
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.
@@ -878,6 +888,46 @@ def __next__(self) -> str: | |||
return newline.lstrip("\n") | |||
|
|||
|
|||
# Wrapper that wraps a StringIO buffer and reads bytes from it | |||
# Created for compat with pyarrow read_csv | |||
class BytesIOWrapper(io.BytesIO): |
There was a problem hiding this comment.
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
thanks @lithomas1 very nice! and thanks @twoertwein for reviewing |
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.