writing efficiently a numpy array

Emile van Sebille emile at fenx.com
Thu Feb 28 14:06:21 EST 2002


"Stephan" <stephan.schumacher at andra.fr> wrote in message
news:MPG.16e755abd178b85e989682 at news.wanadoo.fr...
>
> Hi,
>
> I want to write a large numpy array on an ascii file. There must be N
> numbers per line (except for the last line...).
>
> Does anyone knows something more efficient than the function below :
>


Take advantage of Numeric's output formatting, using:

<untested>
for ii in range(0,len(a),N):
    file.write(str(a[ii:ii+N])[1:-1]+"\n")

HTH,

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list