[Numpy-discussion] printing array in tabular form

Sudheer Joseph sudheer.joseph at yahoo.com
Thu May 9 04:06:48 EDT 2013

Thank you Gomersall,
          However writing a formatted out put looks to be bit tricky with python relative to other programing languages.
For example,
     If I wanted to print below text in a file (for reading by another program), it looks to be not an easy job....Hope new developments will come and a userfriendly formatted out put method for pyton will evolve.

IL= 1,2,3,4,5

JL= 1,2,3,4,5

KL= 1,2,3,4,5

with best regards,

Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
E-mail:sjo.India at gmail.com;sudheer.joseph at yahoo.com
Web- http://oppamthadathil.tripod.com

> From: Henry Gomersall <heng at cantab.net>
>To: Discussion of Numerical Python <numpy-discussion at scipy.org> 
>Sent: Wednesday, 8 May 2013 12:23 PM
>Subject: Re: [Numpy-discussion] printing array in tabular form
>On Wed, 2013-05-08 at 10:13 +0800, Sudheer Joseph wrote:
>> However I get below error. Please tell me if any thing I am missing.
>> file "read_reg_grd.py", line 22, in <module>
>>     np.savetxt("file.txt", IL.reshape(-1,5), fmt='%5d', delimiter=',')
>> AttributeError: 'list' object has no attribute 'reshape'
>IL is a list, not a numpy array. You can either convert the list to an
>array after you've filled it, using np.array(IL), or you can
>pre-allocate the array and fill it directly in the loop.
>NumPy-Discussion mailing list
>NumPy-Discussion at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130509/01a099f9/attachment.html>

More information about the NumPy-Discussion mailing list