Skip to content
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

[Python] read_csv shouldn't close file handles it doesn't own #21340

Closed
asfimport opened this issue Mar 11, 2019 · 3 comments
Closed

[Python] read_csv shouldn't close file handles it doesn't own #21340

asfimport opened this issue Mar 11, 2019 · 3 comments

Comments

@asfimport
Copy link

If a file-handle is passed into read_csv it is automatically closed:

 

In [47]: csv = io.BytesIO(b'''issue_date_utc,variable_name,station_name,station_id,value_date_utc,value
    ...: 2019-02-26 22:00:00,TEMPERATURE,ARCHERFIELD,040211,2019-02-27 03:00,29.1
    ...: ''')

In [48]: pa.csv.read_csv(csv, convert_options=opts)
Out[48]:
pyarrow.Table
issue_date_utc: timestamp[ns]
variable_name: string
station_name: string
station_id: int64
value_date_utc: string
value: double

In [49]: csv.seek(0)
Traceback (most recent call last):

  File "<ipython-input-50-0644e6e50712>", line 1, in <module>
    csv.seek(0)

ValueError: I/O operation on closed file.

 

This behaviour is in contrast to pandas which leaves the file handle open.

Since the function didn't create the file handle I don't think it should close it.

Reporter: Dave Hirschfeld / @dhirschfeld
Assignee: Wes McKinney / @wesm

PRs and other links:

Note: This issue was originally created as ARROW-4823. Please see the migration documentation for further details.

@asfimport
Copy link
Author

@asfimport
Copy link
Author

Wes McKinney / @wesm:
If you can, please add "[TAG]" to the PR subject titles which helps us see at a glance what kind of issue something is (without looking at the Component JIRA field)

@asfimport
Copy link
Author

Wes McKinney / @wesm:
Issue resolved by pull request 4610
#4610

@asfimport asfimport added this to the 0.14.0 milestone Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants