Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 5:13 pm, Stephen Hansen wrote: > On 6/21/10 4:26 PM, davidgp wrote: > > > > > > > ah, i see :P > > float("45.34") or whatever does work fine, but the problem is that i'm > > reading it from a text file. so somehow it is not a real string or > > whatever.. > > here's a part of the code:

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:26 PM, davidgp wrote: > ah, i see :P > float("45.34") or whatever does work fine, but the problem is that i'm > reading it from a text file. so somehow it is not a real string or > whatever.. > here's a part of the code: > f = open ('/home/david/out.txt', 'r') > > for line in f: > if

Re: float from numbers in text file

2010-06-21 Thread GMail Felipe
On 21/06/2010, at 20:26, davidgp wrote: On Jun 21, 4:18 pm, Stephen Hansen wrote: On 6/21/10 4:03 PM, davidgp wrote: sorry :) Okay, I should be more specific: include full tracebacks and some real copied and pasted code :) Don't throw away nice debugging information Python gave you,

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 4:18 pm, Stephen Hansen wrote: > On 6/21/10 4:03 PM, davidgp wrote: > > > > > sorry :) > > Okay, I should be more specific: include full tracebacks and some real > copied and pasted code :) Don't throw away nice debugging information > Python gave you, feed it to us. > > > invalid liter

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:03 PM, davidgp wrote: > > sorry :) Okay, I should be more specific: include full tracebacks and some real copied and pasted code :) Don't throw away nice debugging information Python gave you, feed it to us. > invalid literal for long() with base 10: '51.9449702' > this is the error

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 4:00 pm, Stephen Hansen wrote: > On 6/21/10 3:54 PM, davidgp wrote: > > > i basically tried this: > > lat =0.0 > > for line in f: > >   lat = float(line) > > > but this gives an error.. does anyone know what i should to do? > > thanks, > > "An error"? > > Python 2.6.1 (r261:67515, Feb 1

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 3:54 PM, davidgp wrote: > i basically tried this: > lat =0.0 > for line in f: > lat = float(line) > > but this gives an error.. does anyone know what i should to do? > thanks, "An error"? Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin

float from numbers in text file

2010-06-21 Thread davidgp
hello, i have a text file that contains gps coordinates that i want to load into my mysql database the file is basically in this format: 52.2375412 5.1802704 i basically tried this: lat =0.0 for line in f: lat = float(line) but this gives an error.. does anyone know what i should to do? thanks,