Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38658
| Date | 2013-02-11 12:00 +0100 |
|---|---|
| Subject | Error in reading and writing CSV format file in python |
| From | inshu chauhan <insideshoes@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1634.1360580421.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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
<module>
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Error in reading and writing CSV format file in python inshu chauhan <insideshoes@gmail.com> - 2013-02-11 12:00 +0100
Re: Error in reading and writing CSV format file in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-11 23:26 +1100
Re: Error in reading and writing CSV format file in python inshu chauhan <insideshoes@gmail.com> - 2013-02-11 13:44 +0100
Re: Error in reading and writing CSV format file in python MRAB <python@mrabarnett.plus.com> - 2013-02-11 13:02 +0000
Re: Error in reading and writing CSV format file in python inshu chauhan <insideshoes@gmail.com> - 2013-02-11 14:09 +0100
csiph-web