<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 11, 2013 at 3:22 PM, Dave Angel <span dir="ltr"><<a href="mailto:davea@davea.name" target="_blank">davea@davea.name</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 02/11/2013 06:00 AM, inshu chauhan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In the programme below I am trying to read two csv format files and process<br>
them and write a new file with some of theirs data.<br>
<br>
import csv<br>
f1_reader = csv.reader(open(r"Z:\Weka<br>
work\Feature_Vectors_Fullset_<u></u>00.arff"))<br>
f2_reader = csv.reader(open(r"Z:\Weka<br>
work\Feature_Vectors_Fullset_<u></u>00_noxy+class.arff"))<br>
nf = open(r"Z:\Weka work\classified_image00_<u></u>withoutxy.arff", "w")<br>
<br>
while True:<br>
     l1 = f1_reader.next()<br>
     while len(l1) != 12:<br>
         l1 = f1_reader.next()<br>
     l2 = f2_reader.next()<br>
     while len(l2) != 11:<br>
         l2 = f2_reader.next()<br>
<br>
     ix = l1[0].strip()<br>
     iy = l1[1].strip()<br>
     classification = l2[8].strip()<br>
<br>
     print >> nf, ix, iy, classification<br>
<br>
nf.close()<br>
<br>
This programme is giving me this error now :<br>
<br>
Traceback (most recent call last):<br>
   File "Z:\Weka work\final_image_<u></u>classificationwithoutxy.py", line 16, in<br>
<module><br>
     l2 = f2_reader.next()<br>
StopIteration<br>
<br>
<br>
what could be a possible reason to StopIteration ???<br>
<br>
<br>
I checked the syntax and usage of this module looks alright to me , but<br>
then why this error ?<br>
<br>
<br>
</blockquote>
<br></div></div>
That's not an error, it's just a normal way to end a for-loop.  If you were using a syntax like:<br>
  for item in f2_reader:<br>
<br>
the StopIteration would simply end the loop.  Since you're doing it manually, you have to handle the exception yourself.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
-- <br>
DaveA<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Yes , therefore I used try and except. <br></div></div>