[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Formatting arrays using myarrayy.tolist

Abrahams, Max

2/6/2008 5:18:00 PM

I've got an array that looks like this:


>>> p.xv[20:25]

array([[ 1.60783821e-01, 1.04174046e+01, -1.74045566e-03,
6.02421398e-01, 2.16078382e+00, -1.60783821e-02],
[ 1.66704816e-01, 1.04390422e+01, -1.90421758e-03,
5.81767402e-01, 2.16670482e+00, -1.66704816e-02],
[ 1.72418976e-01, 1.04607380e+01, -2.07379715e-03,
5.61054649e-01, 2.17241898e+00, -1.72418976e-02],
[ 1.77925722e-01, 1.04824899e+01, -2.24898715e-03,
5.40285230e-01, 2.17792572e+00, -1.77925722e-02],
[ 1.83224500e-01, 1.05042958e+01, -2.42957975e-03,
5.19461244e-01, 2.18322450e+00, -1.83224500e-02]])

I want to dump it to a plain text file. The problem is, it unravels
the array. The text file will look like this

p.xv.tofile('file','\n')


10.3528613872
-0.00128613872188
0.664009998909
2.14178590964
-0.0141785909637
0.148323738585
10.3743121062
-0.0014312106189

and so on.
i want it to look like this:

1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24


any help would be appreciated.
thanks.
5 Answers

Colin J. Williams

2/6/2008 6:52:00 PM

0

Max Abrahams wrote:
> I've got an array that looks like this:
>
>
>> >> p.xv[20:25]
>
> array([[ 1.60783821e-01, 1.04174046e+01, -1.74045566e-03,
> 6.02421398e-01, 2.16078382e+00, -1.60783821e-02],
> [ 1.66704816e-01, 1.04390422e+01, -1.90421758e-03,
> 5.81767402e-01, 2.16670482e+00, -1.66704816e-02],
> [ 1.72418976e-01, 1.04607380e+01, -2.07379715e-03,
> 5.61054649e-01, 2.17241898e+00, -1.72418976e-02],
> [ 1.77925722e-01, 1.04824899e+01, -2.24898715e-03,
> 5.40285230e-01, 2.17792572e+00, -1.77925722e-02],
> [ 1.83224500e-01, 1.05042958e+01, -2.42957975e-03,
> 5.19461244e-01, 2.18322450e+00, -1.83224500e-02]])
>
> I want to dump it to a plain text file. The problem is, it unravels the
> array. The text file will look like this
>
> p.xv.tofile('file','\n')
>
>
> 10.3528613872
> -0.00128613872188
> 0.664009998909
> 2.14178590964
> -0.0141785909637
> 0.148323738585
> 10.3743121062
> -0.0014312106189
>
> and so on.
> i want it to look like this:
>
> 1 2 3 4 5 6
> 7 8 9 10 11 12
> 13 14 15 16 17 18
> 19 20 21 22 23 24
>
>
> any help would be appreciated.
> thanks.
array is for single dimension arrays.

You might look at numpy which deals with
multidimensional arrays.

Colin W.

gmaximus6

2/6/2008 6:59:00 PM

0

sorry, i should've been more specific, this is a numpy array.

Alan G Isaac

2/6/2008 7:42:00 PM

0

Robert Kern

2/6/2008 11:26:00 PM

0

gmaximus6@gmail.com wrote:
> sorry, i should've been more specific, this is a numpy array.

It's usually best to ask numpy questions on the numpy mailing list for this reason.

http://www.scipy.org/Mai...

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

kangarooistan

10/23/2008 7:05:00 PM

0

Dean Jones wrote:
> Dirty camel fucker!
>
> On Oct 21, 9:56 am, kangarooistan8 <kangarooist...@gmail.com> wrote:
>> -------------------------------------------------------------
>>
>> Tuesday 21st October, 2008
>> # 8:30
>>
>> First Australians: There is No Other Law
>> Send to a friend
>> #
>>
>> There is No Other Law - Throughout the history of white settlement,
>> individual white men, good and bad, have significantly affected the
>> first Australians.
>>
>> Supported by pastoralists keen to make their
>> fortune, the homicidal police officer Constable Willshire, brings
>> mayhem to the Arrernte nation in Central Australia.
>>
>> With the authorities turning a blind eye, the telegraph operator
>> Frank Gillen stops him. Gillen's other legacy is comprehensive
>> records of the Arrernte people's way of life. (Commissioned by SBSi,
>> in English) CC
>> WS
>> Visit Websitehttp://www.sbs.com.au/schedule/2...
>> ---------------------------------------------------------------
>
HOW TO BECOME A SHITSKIN MOSLEM - this is how: fuck goats, fuck your
mother (nikomak), molest children, wear a beekeepers outfit all the
time, never shower or bath, beat your wives, learn terrorist activities
at a maddrassa, wipe your ass with stones, sell the donkey you fucked to
a nearby village, marry a nine year-old , send your child off to an
indoctrination camp, practice thighing with little kids, ............
Practice all those and you too could become a prophet !!


Elif air ab tizak mohammad !!!!

info@muslimmatch.com or apache@muslimmatch.com or
Achmat.Samsodien@gmail.com
ipcisa@yebo.co.za
politicsIranian@googlegroups.com
jamiat@islamsa.org.za
dsirc@mweb.co.za
arah1958@gmail.com
jamiatmp@lantic.co.za
sanha-kzn@sanha.org.za
sanha-gp@sanha.org.za
sanha-cpt@sanha.org.za
helpline@sanha.org.za
islamwayoflife@googlegroups.com
furtivo4000@gmail.com

** Posted from http://www.te... ** moslem cartoon character
mohammad and his bumchum allaah were child molesting goat fuckers and
nikomaks


_
/'_/)
,/_ /
/ /
/'_'/' '/'__'7,
/'/ / / /" /_ ('( ' /' ')
\ /
'\' _.7'
\ (
\
Up your ass mohammad - Elif air ab tizak!!!

info@muslimmatch.com or apache@muslimmatch.com or
politicsIranian@googlegroups.com
Achmat.Samsodien@gmail.com
jamiat@islamsa.org.za
dsirc@mweb.co.za
jamiatmp@lantic.co.za
sanha-kzn@sanha.org.za
sanha-gp@sanha.org.za
sanha-cpt@sanha.org.za
helpline@sanha.org.za
arah1958@gmail.com
islamwayoflife@googlegroups.com
furtivo4000@gmail.com
ipcisa@yebo.co.za

** Posted from http://www.te... **