Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38667

Re: Error in reading and writing CSV format file in python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
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; 'subject:python': 0.11; 'file,': 0.15; 'csv': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'subject:CSV': 0.16; 'subject:writing': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'module': 0.19; 'trying': 0.21; 'import': 0.21; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; '(most': 0.27; '???': 0.27; 'error': 0.30; 'checked': 0.30; 'file': 0.32; 'could': 0.32; 'print': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'next': 0.35; 'but': 0.36; 'data.': 0.36; 'possible': 0.37; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'skip:w 30': 0.61; 'reached': 0.65; 'header:Reply-To:1': 0.68; 'programme': 0.69; 'reply-to:no real name:2**0': 0.72; '11:': 0.84; '12:': 0.84; 'reply-to:addr:python.org': 0.84; 'theirs': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=XeZXOvF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=Tv4_tr9OjFAA:10 a=VyFPsJH9IiwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=ZL2lUrT8GQwA:10 a=yIEoWkZjbMsdZDnK-agA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Mon, 11 Feb 2013 12:27:11 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Error in reading and writing CSV format file in python
References <CAFqGZRH4AVa8aXsa_51wFh+9+OAcEifB=MMk9eSPXWgtgCLsVQ@mail.gmail.com>
In-Reply-To <CAFqGZRH4AVa8aXsa_51wFh+9+OAcEifB=MMk9eSPXWgtgCLsVQ@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1638.1360585619.2939.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360585619 news.xs4all.nl 6952 [2001:888:2000:d::a6]:53914
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38667

Show key headers only | View raw


On 2013-02-11 11:00, inshu chauhan wrote:
> 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 ?
>
It has reached the end of the file, there's no next line.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Error in reading and writing CSV format file in python MRAB <python@mrabarnett.plus.com> - 2013-02-11 12:27 +0000

csiph-web