Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'syntax': 0.03; 'subject:Error': 0.07; 'subject:file': 0.07; '"w")': 0.09; 'advance': 0.10; 'subject:python': 0.11; '>>': 0.16; 'csv': 0.16; 'subject:CSV': 0.16; 'subject:writing': 0.16; 'thankyou': 0.16; 'true:': 0.16; 'module': 0.19; 'to:name:python- list@python.org': 0.20; 'trying': 0.21; 'import': 0.21; 'looks': 0.26; '(most': 0.27; '???': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:& 10': 0.29; 'error': 0.30; 'checked': 0.30; 'file': 0.32; 'could': 0.32; 'print': 0.32; 'traceback': 0.33; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'but': 0.36; 'data.': 0.36; 'possible': 0.37; 'two': 0.37; 'why': 0.37; 'files': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'skip:w 30': 0.61; 'programme': 0.69; '11:': 0.84; '12:': 0.84; 'theirs': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=GCP2kEqwHJceKIxpnwEg71DGwMHR0G8Ck5BLUhXBe8Y=; b=NrILDuu3e0noL3+Ax6YxC7lhjn5cdvxgOAOkt7ZUrX3DqtP1rdXOVguPWC57O4aXbG 5WLELQwtIn4u7uNWFaPslvUu6EGHv6jSzN0V0PbrMVqCXG4ghjpU4RztXnDClybm7842 qmi25wghp0wKpcezjn+qkInczUvDaQP2p+wEbl9YK+R3CXg0upPJOxkZTZt0d2+jPhIN VjKWQDAo9NpNxV986xoEDum139pdP2s43Lup5PQUy9yeRdSyA2PCkP0OTQjRT9fm4HKa xapjoab0NzMsy6E+L+tncwWn3GoJ6L46SG0HvfLm+yQiAmLWsUymGrQ+SfWLrUMt+xVZ zQpg== MIME-Version: 1.0 X-Received: by 10.50.219.228 with SMTP id pr4mr3282838igc.40.1360580412249; Mon, 11 Feb 2013 03:00:12 -0800 (PST) Date: Mon, 11 Feb 2013 12:00:12 +0100 Subject: Error in reading and writing CSV format file in python From: inshu chauhan To: "python-list@python.org" Content-Type: multipart/alternative; boundary=bcaec555513c2917b704d570d081 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360580421 news.xs4all.nl 6888 [2001:888:2000:d::a6]:45239 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38658 --bcaec555513c2917b704d570d081 Content-Type: text/plain; charset=ISO-8859-1 In the programme below I am trying to read two csv format files and process them and write a new file with some of theirs data. import csv f1_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00.arff")) f2_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00_noxy+class.arff")) nf = open(r"Z:\Weka work\classified_image00_withoutxy.arff", "w") while True: l1 = f1_reader.next() while len(l1) != 12: l1 = f1_reader.next() l2 = f2_reader.next() while len(l2) != 11: l2 = f2_reader.next() ix = l1[0].strip() iy = l1[1].strip() classification = l2[8].strip() print >> nf, ix, iy, classification nf.close() This programme is giving me this error now : Traceback (most recent call last): File "Z:\Weka work\final_image_classificationwithoutxy.py", line 16, in l2 = f2_reader.next() StopIteration what could be a possible reason to StopIteration ??? I checked the syntax and usage of this module looks alright to me , but then why this error ? Thankyou in Advance --bcaec555513c2917b704d570d081 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
In the programme below I am trying to = read two csv format files and process them and write a new file with some o= f theirs data.

import csv
f1_reader =3D csv.reader(open(r"Z:= \Weka work\Feature_Vectors_Fullset_00.arff"))
f2_reader =3D csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_0= 0_noxy+class.arff"))
nf =3D open(r"Z:\Weka work\classified_ima= ge00_withoutxy.arff", "w")

while True:
=A0=A0=A0 l= 1 =3D f1_reader.next()
=A0=A0=A0 while len(l1) !=3D 12:
=A0=A0=A0=A0=A0=A0=A0 l1 =3D f1_reader.= next()
=A0=A0=A0 l2 =3D f2_reader.next()
=A0=A0=A0 while len(l2) !=3D= 11:
=A0=A0=A0=A0=A0=A0=A0 l2 =3D f2_reader.next()

=A0=A0=A0 ix = =3D l1[0].strip()
=A0=A0=A0 iy =3D l1[1].strip()
=A0=A0=A0 classifica= tion =3D l2[8].strip()

=A0=A0=A0 print >> nf, ix, iy, classification

nf.close()
This programme is giving me this error now :

Traceback = (most recent call last):
=A0 File "Z:\Weka work\final_image_classif= icationwithoutxy.py", line 16, in <module>
=A0=A0=A0 l2 =3D f2_reader.next()
StopIteration


what co= uld be a possible reason to StopIteration ???


I checked t= he syntax and usage of this module looks alright to me , but then why this = error ?


Thankyou in Advance
--bcaec555513c2917b704d570d081--