List Info

Thread: Re: read text file in zip archive, process, plot




Re: read text file in zip archive, process, plot
country flaguser name
Norway
2007-04-15 06:52:09
Thank you both! That seems to make my code much more
clear... I thought
it was foolish writing files, but I just couldn't determine
how to
parse the data!

Kent, one thing, regarding:
        x = []
        t = []
        for l in data[stind:-1]:
                l = l.split()  # Split on whitespace
                tval = float(l[0])
                t.append(tval)
                xval = float(l[24])
                x.append(xval)

note that I had to change to [stind:-1] I believe I must
have a blank
line at the end of the file... 

.j


____________________________________________________________
____________
Interested in getting caught up on today's news?
Click here to checkout USA TODAY Headlines.
http://track.juno.com/s/l
c?s=198954&u=http://www.usatoday.com/news/front.htm?csp=
24


_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor

Re: read text file in zip archive, process, plot
user name
2007-04-15 07:39:29
* Washakie Wyoming <washakiejuno.com> [070415
14:25]:
> Thank you both! That seems to make my code much more
clear... I thought
> it was foolish writing files, but I just couldn't
determine how to
> parse the data!
> 
> Kent, one thing, regarding:
>         x = []
>         t = []
>         for l in data[stind:-1]:
>                 l = l.split()  # Split on whitespace
>                 tval = float(l[0])
>                 t.append(tval)
>                 xval = float(l[24])
>                 x.append(xval)
> 
> note that I had to change to [stind:-1] I believe I
must have a blank
> line at the end of the file...
That depends upon the platform. Under Unix, files are meant
to be
ending in a n, so you get an empty line at the end. But
nobody
enforces that.

So personally, I'd probably add something like this to the
loop:
       l = l.split()
       if not l:
           continue

This way the loop ignores empty lines.

Andreas
_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )