Breaking String into Values

Terry Reedy tejarex at yahoo.com
Fri Mar 29 17:43:03 EST 2002


"robert garretson wright" <rgwright at ux.cso.uiuc.edu> wrote in message
news:HD5p8.33836$tg4.398811 at vixen.cso.uiuc.edu...
> I am working on reading in a data file format which is set up as a
series
> of lines that look like this:
>
> 3500035000010104A Foo 45
>
> I want to break up into a variables as follows:
> a = 35000, b = 35000, c = 10104, d = 'A', e = 'Foo', f = 45
>
> My current code (auto-generated from a data dictionary) looks
> something like this:
>
> temp = line[0:5]
> a = int(temp)

It would be slightly and to me easier to read without the 'temp' vars.

...

> Is there a better way to do this? The files have around 1000-8000
lines each
> so I would like it to be fast.

What times are you trying to improve on?  When I did comparable
projects, (on a 3+ year old PC) input and conversion only took a few
seconds, as I remember.

Terry J. Reedy






More information about the Python-list mailing list