Writing 2d array in an ascci file

C

charles.hebert

Hi,

I want to write an 2d array in an ascii file using numpy. There's the -
tofile / fromfile - function but it doesn't work with nd array.

Thanks,

CH.
 
J

Jeremy Sanders

I want to write an 2d array in an ascii file using numpy. There's the -
tofile / fromfile - function but it doesn't work with nd array.

Is this good enough?

x = numpy.zeros( (10, 10) )
f = open('out.txt', 'w')
print >>f, str(x).replace('[',' ').replace(']', ' ')
f.close()


Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top