[NumPy-Tickets] [NumPy] #1752: np.loadtxt fails on empty files

NumPy Trac numpy-tickets@scipy....
Wed Mar 2 16:19:50 CST 2011

#1752: np.loadtxt fails on empty files
 Reporter:  weathergod   |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  normal       |   Milestone:  1.6.0   
Component:  Other        |     Version:  1.5.1   
 Keywords:               |  
 loadtxt() should return an empty array instead of raising an exception for
 an empty (but existing!) file.  This behavior would be consistent with

 import numpy as np
 from StringIO import StringIO

 a = np.loadtxt(StringIO(""))
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/bvr/Programs/numpy/numpy/lib/npyio.py", line 748, in loadtxt
     raise IOError('End-of-file reached before encountering data.')
 IOError: End-of-file reached before encountering data.

 This has occurred since version 1.2, I believe.  The current behavior is
 an improvement over previous versions, where numpy would hang on empty
 files.  Therefore, I am filing this as an enhancement request.

Ticket URL: <http://projects.scipy.org/numpy/ticket/1752>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list