There have been some recent attempts to improve the error reporting in
genfromtxt <http://projects.scipy.org/numpy/ticket/1212>, which is
great, because hunting down the problems reading in big and messy
files is not fun.
I am working on a patch that keeps up with the line number and column
number of where you are in parsing the file, so that this can be
reported in the error. Is there a way to catch a raised error and add
to it?
For instance, I have a problem in my file which leads to this error
being raised from np.lib._iotools.StringCoverter.upgrade
ValueError: Converter is locked and cannot be upgraded
I added this into np.lib.io.genfromtxt around line 995.
linenum = 0
[...]
if dtype is None:
try:
colnum = 0
for (converter, item) in zip(converters, values):
converter.upgrade(item)
colnum += 1
except:
raise ValueError, "I don't report the error from
_iotools.StringConverter.upgrade, but I do know that there is a
problem trying to convert a value at line %s and column %s" %
(linenum,colnum)
[...]
linenum += 1
I'd like to add line and column number information to original error
from _iotools. Any suggestions?
Cheers,
Skipper
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion