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
REF: move get_filepath_buffer into get_handle #37639
Conversation
3a956a3
to
42e6756
Compare
e1ba2d8
to
9fc1834
Compare
3e8100a
to
ed51677
Compare
129a384
to
16e404e
Compare
f73054b
to
6b80fb0
Compare
thanks @twoertwein very nice! |
@twoertwein I have a question about the code you added in this PR. In #31817 I'm adding a new csv reader engine (pyarrow) to which I have to provide class BytesIOWrapper:
"""
Allows the pyarrow engine for read_csv() to read from string buffers
"""
def __init__(self, string_buffer: StringIO, encoding: str = "utf-8"):
self.string_buffer = string_buffer
self.encoding = encoding
def __getattr__(self, attr: str):
return getattr(self.string_buffer, attr)
def read(self, size: int = -1):
content = self.string_buffer.read(size)
return content.encode(self.encoding) but I'm wondering if this can be done using Thanks so much! |
Yes, Towards the end of I assume that the following code might get you quite far if not (is_text or _is_binary_mode(handle, mode)):
handle = BytesIOWrapper(handle, encoding)
mode = mode.replace("b", "") |
@arw2019 I think that the About adding the |
@twoertwein Thank you so much for these responses!!! I'm thinking I'll do a separate PR to add the |
…straint due to renaming of `get_filepath_or_buffer` pandas-dev/pandas#37639 pandas-dev/pandas@6d1541e#diff-934d8564d648e7521db673c6399dcac98e45adfd5230ba47d3aabfcc21979febL247 PEtab-dev/PEtab#493
…fer` private without major release (semver!?) pandas-dev/pandas#37639 pandas-dev/pandas@6d1541e#diff-934d8564d648e7521db673c6399dcac98e45adfd5230ba47d3aabfcc21979febL247
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
Fixes pandas-dev#48700 Refs pandas-dev#9245 Refs pandas-dev#37639 Regressed in 6d1541e
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This PR makes
get_filepath_buffer
a private function and is called insideget_handle
- one function to rule all of IO ;)This PR will make it easier for future PRs to make the IO-related interface of
read/to_*
more consistent as most of them should support compression/memory mapping (for reading)/(binary) file handles/storage options.Notes to keep track of future follow-up PRs:
get_handle
storage_options
forto_excel