[Numpy-discussion] Question about improving genfromtxt errors

Bruce Southey bsouthey@gmail....
Fri Sep 25 13:03:02 CDT 2009

On 09/25/2009 12:00 PM, Skipper Seabold wrote:
> 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
I am guessing that the converter is most likely causing the error. So 
presumably the file is read correctly without using the converter. If 
not then you should address that first.

If it is an input file, then what is it and the how is genfromtxt called?

A question regarding the ticket than this, why do you want to raise an 

The reason I did not do it was that it was helpful to identify all of 
the lines that have a specific problem. You can not assume that a user 
will fix all lines with this problem let alone fix all lines with 
similar problems.


More information about the NumPy-Discussion mailing list