[Tutor] manipulting CSV files
lowelltackett at yahoo.com
Fri Jan 8 16:56:01 CET 2010
>From the virtual desk of Lowell Tackett
--- On Fri, 1/8/10, Kent Johnson <kent37 at tds.net> wrote:
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] manipulting CSV files
> To: "Lowell Tackett" <lowelltackett at yahoo.com>
> Cc: "tutor" <Tutor at python.org>
> Date: Friday, January 8, 2010, 10:07 AM
> Well, it's right - that is not a valid integer. What do you
> want to do
> with it? You could convert it to a number with
> float(line) or get
> just the integer part with int(line.split('.')).
I hadn't grasped the subtle meaning of "int()"; thanks, that helps. So, here's the (happy) result:
>>> coord = csv.reader(open('true_coord', 'rb'), skipinitialspace = True)
>>> for line in coord:
.... if line == '1001':
.... print [float(line) + float(line)]
Please keep in mind, as I'd mentioned earlier, all of this is fairly new concepts to me; from running an interpretive Python screen, to delving into the zen of computing, [even] to pasting stuff from there to here--there's about 4 different "Learn Python and Make New Friends" books strewn around me and my computer desk right now, opened to different subjects (and the Joy of Google waiting on the internet) and with all that I want to develop to where I can create some pretty expansive scripts dealing with land surveying stuff--manipulating coordinates, inversing, traversing, bearings, etc., etc.
Ya'll are meeting me here pretty much on the proverbial "First Step" of the 1000-mile journey, so all the help is very welcome and appreciated. Thanks.
More information about the Tutor