[SciPy-user] Wriitng a list to an ascii file

Nils Wagner nwagner@iam.uni-stuttgart...
Wed Feb 14 06:53:58 CST 2007


Hi,

I have a list

>>> data[0]
[1, 3.98, 3.131435898787629, 146.25144654434166]
>>> data[1]
[2, 4.0014113157358633, -0.23777483140261779, 169.32304332115922]
>>> data[2]
[3, 4.0000070483264265, -0.0011815833829018629, 167.64445564164987]
>>> data[3]
[4, 4.0000000001757536, -2.946728727692971e-08, 167.63609488306861]

where the first entry is an integer and the remaining entries are floats.

How can I write this list to an ascii file without destroying the
integer type of the first entry?

Nils
 
io.write_array() yields

1.000000000000000e+00 3.980000000000000e+00 3.131435898787629e+00
1.462514465443417e+02
2.000000000000000e+00 4.001411315735863e+00 -2.377748314026178e-01
1.693230433211592e+02
3.000000000000000e+00 4.000007048326427e+00 -1.181583382901863e-03
1.676444556416499e+02
4.000000000000000e+00 4.000000000175754e+00 -2.946728727692971e-08
1.676360948830686e+02

but I would prefer

1 3.980000000000000e+00 3.131435898787629e+00 1.462514465443417e+02
2 4.001411315735863e+00 -2.377748314026178e-01 1.693230433211592e+02
3 4.000007048326427e+00 -1.181583382901863e-03 1.676444556416499e+02
4 4.000000000175754e+00 -2.946728727692971e-08 1.676360948830686e+02

 


More information about the SciPy-user mailing list