<font color='black' size='2' face='arial'>
<div style="CLEAR: both">I checked out the csv module and got a little further along, but still can't quite figure out how to iterate line by line properly. </div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both"># This shows that I'm reading the file in correctly:</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">input_file=open("test-8-29-10.csv","rb")<br>
for row in input_file:<br>
print row</div>
<div style="CLEAR: both"><br>
MyWord,Category,Ct,CatCt</div>
<div style="CLEAR: both">!,A,2932,456454</div>
<div style="CLEAR: both">!,B,2109,64451</div>
<div style="CLEAR: both">a,C,7856,90000</div>
<div style="CLEAR: both">abandoned,A,11,456454<br>
....</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both"># But when I try to add columns, I'm only filling in some static value. So there's something wrong with my looping.</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">testReader=csv.reader(open('test-8-29-10.csv', 'rb'))<br>
for line in testReader:<br>
for MyWord, Category, Ct, CatCt in testReader:<br>
text=nltk.word_tokenize(MyWord)<br>
word2=wnl.lemmatize(word)<br>
word3=porter.stem(word)<br>
print MyWord+","+Category+","+Ct+","+CatCt+","+word+","+word2+","+word3+"\r\n"</div>
<div style="CLEAR: both"> <br>
!,A,2932,456454,yrs,yr,yr</div>
<div style="CLEAR: both">!,B,2109,64451,yrs,yr,yr</div>
<div style="CLEAR: both">a,C,7856,90000,yrs,yr,yr</div>
<div style="CLEAR: both">abandoned,A,11,456454,yrs,yr,yr<br>
...</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both"># I tried adding another loop, but it gives me an error.</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">testReader=csv.reader(open('test-8-29-10.csv', 'rb'))<br>
for line in testReader:<br>
for MyWord, Category, Ct, CatCt in line: # I thought this line inside the other was clever, but, uh, not so much<br>
text=nltk.word_tokenize(MyWord)<br>
word2=wnl.lemmatize(word)<br>
word3=porter.stem(word)<br>
print MyWord+","+Category+","+Ct+","+CatCt+","+word+","+word2+","+word3+"\r\n"</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">Traceback (most recent call last):<br>
File "<pyshell#256>", line 2, in <module><br>
for MyWord, Category, Ct, CatCt in line:<br>
ValueError: too many values to unpack</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">My hope is that once I can figure out this problem, it'll be easy to write the csv file with the csv module. But I'm stumped about the looping.</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">Thanks for any suggestions,</div>
<div style="CLEAR: both"> </div>
<div style="CLEAR: both">Tyler</div>
</font>