[
https://issues.apache.org/jira/browse/ARROW-11939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17303345#comment-17303345
]
Diana Clarke edited comment on ARROW-11939 at 3/17/21, 12:33 PM:
-----------------------------------------------------------------
{{PythonFile}} is expecting a file object, not a path to a file.
[https://arrow.apache.org/docs/python/generated/pyarrow.PythonFile.html]
For example:
{code:java}
import pyarrow
import pyarrow.parquet
with open("foo.parquet", "rb") as f:
table = pyarrow.parquet.read_table(pyarrow.PythonFile(f))
{code}
There is also this use case, as exemplified by this unit test:
{code}
def test_python_file_readall():
data = b'some sample data'
buf = BytesIO(data)
with pa.PythonFile(buf, mode='r') as f:
assert f.readall() == data
{code}
Hope that helps!
was (Author: dianaclarke):
{{PythonFile}} is expecting a file object, not a path to a file.
[https://arrow.apache.org/docs/python/generated/pyarrow.PythonFile.html]
For example:
{code:java}
import pyarrow
import pyarrow.parquet
with open("foo.parquet", "rb") as f:
table = pyarrow.parquet.read_table(pyarrow.PythonFile(f))
{code}
> Bug in `pa.PythonFile`?
> -----------------------
>
> Key: ARROW-11939
> URL: https://issues.apache.org/jira/browse/ARROW-11939
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Affects Versions: 3.0.0
> Reporter: Dave Hirschfeld
> Assignee: Diana Clarke
> Priority: Major
>
> ```python
> with pa.PythonFile('deleteme.jnk', 'wb') as f: pass
> AttributeError: 'str' object has no attribute 'closed'
> ```
--
This message was sent by Atlassian Jira
(v8.3.4#803005)