[Numpy-tickets] [NumPy] #404: numpy.fromfile on file-like object

NumPy numpy-tickets at scipy.net
Wed Dec 20 19:53:48 CST 2006

#404: numpy.fromfile on file-like object
 Reporter:  eisele      |        Owner:  somebody
     Type:  defect      |       Status:  new     
 Priority:  normal      |    Milestone:          
Component:  numpy.core  |      Version:          
 Severity:  normal      |   Resolution:          
 Keywords:              |  
Comment (by charris):

 I suspect there is a problem finding the size of the piped data. My error
 message if different from yours (unable to seek), so there might be
 something else going wrong. I don't think you need the quotes around
 int32, either. The following works for me:

 In [40]: f = os.popen('cat log')

 In [41]: a = fromstring(f.read(), dtype=uint8)

 In [42]: a.tostring()
 Out[42]: 'hello\nworld\n'

 In [43]: f.close()

 There might be other ways.

Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/404#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.

More information about the Numpy-tickets mailing list