Reading a comma delimited file
Bryan L. Fordham
bfordham at socialistsushi.com
Thu Nov 8 15:11:24 EST 2001
> Here's what it looks like when I'm done:
>
> [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1,
> 20.0, 0.0, 167.30000000000001),
> ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0,
> 6.0999999999999996, 13.9, 0.0, 239.0)]
>
> Just what I need except I don't want all those decimal places.
Are you not happy with the number of decimal places?
If so, play around with this:
>>> x='1.234567'
>>> float(x)
1.234567
>>> import fpformat
>>> fpformat.fix(float(x),2)
'1.23'
>>> fpformat.fix(float(x),0)
'1'
Hope that helps...
--B
More information about the Python-list
mailing list