By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,675 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,675 IT Pros & Developers. It's quick & easy.

Writing 2d array in an ascci file

P: n/a
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.

Sep 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ch************@gmail.com wrote:
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

--
Jeremy Sanders
http://www.jeremysanders.net/
Sep 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.