Behalf Of Raymond
Hettinger
Sent: Wednesday, April 29, 2009 10:31 AM
To: python-list@python.org
Subject: Re: sorting items in a table problematic because of scientific notation
[John Machin]
> > 'NEAR_DIST'], [('N', 9, 0), ('N', 9, 0), ('F', 19, 1
[John Machin]
> > 'NEAR_DIST'], [('N', 9, 0), ('N', 9, 0), ('F', 19, 11)], [53, 55, '
>
> The data type code for the offending column is "F" which is not in the
> bog-standard dBase III set of C, N, D, and L. The code that you have used
> merely
> returns unchanged the character string that finds
>> Maybe string.ato[if] used to behave that way?
John> Nope.
...
OK, I remember what it was. The C atof()/atoi() functions will stop at the
first non-numeric character. (I believe the more modern strtod/strtof
functions behave the same way.) You could thus call
atof(" 12345 ab
On 29/04/2009 11:33 PM, s...@pobox.com wrote:
>> Thanks. Didn't used to be that way I don't think.
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> float('1.23456789e+004 ')
12345.6
>> Thanks. Didn't used to be that way I don't think.
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> float('1.23456789e+004 ')
12345.6789
John> :-)
Maybe string.ato[if] used to
pobox.com> writes:
> MRAB> FYI:
>
> >>> float(s)
> 105646.365517
>
> MRAB> which saves a few keystrokes.
>
> Thanks. Didn't used to be that way I don't think.
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathemati
Davis, Amelie Y purdue.edu> writes:
>
> Hi All,
>
> I have a
> dbf table outputted by another program that I cannot (I’m pretty sure)
> change the format of.
>
> I use a
> dbf reader code found online (http://code.activestate.com/recipes/362715/
> ) to read the table in and I need to sort it on
MRAB> FYI:
>>> float(s)
105646.365517
MRAB> which saves a few keystrokes. :-)
Thanks. Didn't used to be that way I don't think.
--
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
"XML sucks, dictionaries rock" - Dave Beazley
--
http://mail.python.org/mail
s...@pobox.com wrote:
Amélie> Hi All,
Amélie> I have a dbf table outputted by another program that I cannot
Amélie> (I'm pretty sure) change the format of.
Amélie> I use a dbf reader code found online
Amélie> (http://code.activestate.com/recipes/362715/ ) to read the table
Davis, Amelie Y wrote:
Hi All,
I have a dbf table outputted by another program that I cannot (I’m
pretty sure) change the format of.
I use a dbf reader code found online
(http://code.activestate.com/recipes/362715/ ) to read the table in and
I need to sort it on a particular field but this
Amélie> Hi All,
Amélie> I have a dbf table outputted by another program that I cannot
Amélie> (I'm pretty sure) change the format of.
Amélie> I use a dbf reader code found online
Amélie> (http://code.activestate.com/recipes/362715/ ) to read the table
Amélie> in and I need
11 matches
Mail list logo