Thanks Alan and Kent (for the sorting notes)!
Alan...I guess I thought outfile2 had data. { i.e.,
outfile2=open('missmeas.dat','w') }
My mistake.
Thanks,
Sara
----- Original Message ----
From: Alan Gauld <[EMAIL PROTECTED]>
To: tutor@python.org
Sent: Sunday, July 29, 2007 7:00:12 PM
Subject: Re: [Tutor] attribute error - quick addition
"Sara Johnson" <[EMAIL PROTECTED]> wrote
> Sorry...I forgot a few more lines at the end of the code. Starts
> with "outfile2write..."
> I also added outfile2.sort()
OK, at leasrt we see where the error occcurs. The problem emains that
you are
trying to sort a file which doesn't have a sort method. You need to
sort the data
before saving it.
Alan G.
================
outfile2=open('missmeas.dat','w')
for key in skeys:
fracmiss=1.*numberMissing(z[key].values())/nsites
outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
if fracmiss>0.:
print outstring
outfile2.write(outstring+'\n') #notice explicit newline \n
outfile2.sort()
outfile2.close()
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car
Finder tool.
http://autos.yahoo.com/carfinder/
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor