Read/write 2D data from/to file..?

Grant Edwards grante at visi.com
Sun Feb 11 21:24:59 EST 2007


On 2007-02-12, mech point <srikanth.allu at gmail.com> wrote:
>
> I was able to read the data from file into a two dimensional array
> (lists)
>
> rows=[map(float,line.split())for line in file("data")]
>
> but How to write them back into the file.

for r in rows:
    file.write(" ".join(map(str,r)) + "\n")

-- 
Grant Edwards                   grante             Yow!  My nose feels like a
                                  at               bad Ronald Reagan movie...
                               visi.com            



More information about the Python-list mailing list