-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
recarray fromfile doesn't support file like objects (Trac #1911) #2504
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
Comments
Attachment added by trac user sbreuss on 2011-07-18: records.py.diff |
Note that even for simple float arrays text fromfile requires an actual file descriptor, so it doesn't work with StringIO. |
Is this also related to #6246? |
I don't think so. I think this is an issue about record arrays, binary files, and seeking, so there's no reason it shouldn't be fixable to work with BytesIO. |
The following bug looks to be related: fromfile can take an io class object on Python 3, but not on Python 2. Specifically, the following code runs perfectly on Python 3.4, but produces an IOError on Python 2.7. I'm using numpy 1.9.2. Originally reported at jazzband/pathlib2#7 by @scienceopen import numpy as np
import io
np.array([1.,2.,3.]).tofile("test.dat")
with io.open("test.dat", mode='rb') as f:
print(np.fromfile(f)) EDIT: also see #6632 |
Is there intention to fix this? |
Another change needed here - Supporting |
Original ticket http://projects.scipy.org/numpy/ticket/1911 on 2011-07-18 by trac user sbreuss, assigned to unknown.
The current implementation of the record array fromfile method doesn't support file like objects (e.g. StringIO, io.BytesIO, ...)
By two minor changes in the source this would be possible:
I'm open to any suggestions, a patch for the current master version showing my changes is attached.
Cheers,
Simon Breuss
The text was updated successfully, but these errors were encountered: