Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread Thomas Kirk Gamble
On Wed, 2010-09-29 at 16:36 +0200, David Froger wrote: > Did you try loadtxt? I try to output something in the format 1.538D-06 > with Fortran in order to test reading it with loadtxt, but I always > get 1.538E-06. Where does the 'D' come from? No, I didn't, but I will. Preserving the 'D' isn't

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
program write_txt real(kind=8):: x open(10,file='data.txt') do i = 1,10 x = i*2. write(10,fmt='(2(D12.3))') x,x**2 enddo close(10) end program write_txt In [1]: def expDtofloat(s): ...: return float(s.replace('D','E')) ...: In [2]: x,y = loadtxt('data.txt',unpack=True,c

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
program write_txt real(kind=8):: x open(10,file='data.txt') do i = 1,10 x = i*2. write(10,fmt='(2(D12.3))') x,x**2 enddo close(10) end program write_txt In [1]: x,y = loadtxt('data.txt',unpack=True) --- ValueErr

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
Did you try loadtxt? I try to output something in the format 1.538D-06 with Fortran in order to test reading it with loadtxt, but I always get 1.538E-06. Where does the 'D' come from? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mai

[Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread Thomas Kirk Gamble
I need to convert numbers read from a text file to floating point. The numbers are in the format 1.538D-06 (written by a FORTRAN application) and have varying amounts of whitespace between them from line to line. The function fromstring() deals with the whitespace just fine but 'dtype=float' doesn