[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
    5,5,6,8,0

JL= 1,2,3,4,5
    5,5,6,8,0 

KL= 1,2,3,4,5
    5,5,6,8,0

with best regards,
Sudheer


 
***************************************************************
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
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
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.
>
>Cheers,
>
>Henry
>
>_______________________________________________
>NumPy-Discussion mailing list
>NumPy-Discussion at scipy.org
>http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
-------------- 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