I&#39;m not familiar with numarray, but google told me that their homepage says that you should be using numpy instead (<a href="http://www.stsci.edu/resources/software_hardware/numarray/numarray.html">http://www.stsci.edu/resources/software_hardware/numarray/numarray.html</a>) including a pdf guide to converting (<a href="http://www.stsci.edu/resources/software_hardware/numarray/numarray2numpy.pdf">http://www.stsci.edu/resources/software_hardware/numarray/numarray2numpy.pdf</a>).<div>
<br></div><div>The docs for numarray are still available though, and it looks like numarray has a tostring() method, but I&#39;m not sure what you&#39;re wanting your output to look like exactly, but you might want to look at the tolist() method. There&#39;s also a tofile() method, but that writes out the array as binary data, and it looks like you&#39;re wanting strings. Anyway, all of these methods are documented on this page: <a href="http://stsdas.stsci.edu/numarray/numarray-1.5.html/node39.html">http://stsdas.stsci.edu/numarray/numarray-1.5.html/node39.html</a></div>
<div><br></div><div><a href="http://stsdas.stsci.edu/numarray/numarray-1.5.html/node39.html"></a>Hope that helps, good luck!</div><div>Ryan A<br><br><div class="gmail_quote">On Thu, Mar 11, 2010 at 8:53 AM,  <span dir="ltr">&lt;<a href="mailto:lintzh@science.oregonstate.edu">lintzh@science.oregonstate.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
I am new to this group. May I post a code-related question here? If so, here it goes.<br>
<br>
I am in the process of importing and reading data, reshaping the data to be a 2D array, adding a header file on top (of the new 2D array), and writing a new file. I do this in a loop for many files. I&#39;m using python 2.5 since that is the version distributed with ArcGIS, a software that interfaces with python 2.5. However, I receive the following error when I attempt to write a data matrix created with NumArray. I just reviewed my two sources on Numarray, and I can&#39;t figure out why I can&#39;t write the data. Below is the code and below the code is the error message.<br>

<br>
I&#39;m not sure how to write NumArray lines ot a .txt file (see the the last lines of code).<br>
<br>
CODE STARTS HERE:<br>
<br>
from __future__ import with_statement<br>
<br>
import arcgisscripting, sys, os, string, copy, glob,numarray<br>
<br>
# Create the Geoprocessor Object<br>
gp = arcgisscripting.create()<br>
<br>
<br>
##############<br>
#DIRECTORIES<br>
##############<br>
<br>
workDIR = &quot;C:\\PDSIwork&quot;<br>
resampleDIR = workDIR + &quot;\\resample\\&quot;<br>
ascDIR = workDIR + &quot;\\PDSIdata\\&quot;<br>
<br>
##############<br>
#HEADER<br>
##############<br>
<br>
header = &quot;&quot;&quot;\<br>
ncols         1386<br>
nrows         595<br>
xllcorner     -124.7292<br>
yllcorner     24.6024<br>
cellsize      0.0417<br>
NODATA_value  -9999<br>
&quot;&quot;&quot;<br>
<br>
#############################<br>
#GET RUNLIST AND IMPORT DATA<br>
##############################<br>
<br>
data=[]<br>
os.chdir(ascDIR)<br>
runlist=os.listdir(ascDIR)<br>
#print runlist<br>
for filex in runlist:<br>
    x=open(filex,&#39;r&#39;)<br>
    for i in xrange(824670):<br>
        z=x.readline()<br>
        z=float(z)<br>
        data.append(z)<br>
    print filex<br>
<br>
#############<br>
#RESHAPE DATA<br>
#############<br>
<br>
    data2 = numarray.array(data)<br>
    data3 = numarray.reshape(data2, 595,1386)<br>
    data4=numarray.transpose(data3)<br>
    print len(data4)<br>
<br>
##########################<br>
#RENAME DATA FOR WRITING<br>
#########################<br>
<br>
    os.chdir(resampleDIR)<br>
    h=filex.replace( &#39;.&#39;, &#39;_&#39; )<br>
    outfilename=h+&#39;.txt&#39;<br>
<br>
###################################<br>
#WRITE NEW DATA WITH HEADER ON TOP<br>
###################################<br>
<br>
<br>
#try:<br>
    with open(outfilename,&#39;w&#39;) as outfile:<br>
        outfile.write(header)<br>
        for line in data4:<br>
            line.replace(&#39;[&#39;,&#39; &#39;).replace(&#39;]&#39;,&#39; &#39;)<br>
            outfile.write(line)<br>
<br>
<br>
<br>
---------------------------<br>
Here&#39;s the error message:<br>
---------------------------<br>
<br>
Traceback (most recent call last):  File &quot;C:/PDSIwork/PYTHON_SCRIPTS/RESAMPLER2b.py&quot;, line 74, in &lt;module&gt;    line.replace(&#39;[&#39;,&#39; &#39;).replace(&#39;]&#39;, &#39; &#39;)<br>
AttributeError: &#39;NumArray&#39; object has no attribute &#39;replace&#39;<br>
<br>
Thank you,<br>
Heather<br>
<br>
_______________________________________________<br>
Portland mailing list<br>
<a href="mailto:Portland@python.org" target="_blank">Portland@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/portland" target="_blank">http://mail.python.org/mailman/listinfo/portland</a><br>
</blockquote></div><br></div>