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


Groups > comp.lang.python > #44231

Re: Reading a CSV file

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; 'main()': 0.09; 'rows': 0.09; 'skip:# 30': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; '23,': 0.16; 'better?': 0.16; 'csv': 0.16; 'input:': 0.16; 'main():': 0.16; 'once.': 0.16; 'subject:CSV': 0.16; 'subject:Reading': 0.16; 'wrote:': 0.18; 'example': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'skip:d 20': 0.34; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'starting': 0.37; 'thank': 0.38; 'pm,': 0.38; 'little': 0.38; 'explain': 0.39; '\xa0\xa0\xa0': 0.39; 'url:mail': 0.40; 'how': 0.40; 'to:addr:gmail.com': 0.65; 'to:charset:iso-8859-1': 0.74; 'ana': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=Gz/njE5wsW2uvx7sigkVGp0pM1fZ9vB30tGg2WVEXsk=; b=l7ZRgIS5bSP2jNKEzMKa0InsEcyn87ZNR5V5N70xm8I712qwldxj/KbIvqLNX9LibN FqvXqIifQesu6i9KHPr74HQlAxMJ3B1hhhIaAYetJgST4T8ihjN1wyBA//a3ZPfXoSpM 2YNGdXBHwdKfHFauL00Gecdw/iKoNCHyAJ3BwWV15hlQDRkdhV/F/F4Ak0nHEEJkHJT7 E1iqr+MqLiCeSseaLesUl/D1Xgbu8SEbQ6+tosLEBBtgOs+6LuHOAFhE0elzddahd57f YPhx/D1MzW9X3pIvSo2eNn89hkRd0QLAO4D7NUdUXqWev1xLo8gmNI2XtgdXD4nC43RM OtDA==
MIME-Version 1.0
X-Received by 10.229.0.141 with SMTP id 13mr4063703qcb.80.1366756496947; Tue, 23 Apr 2013 15:34:56 -0700 (PDT)
In-Reply-To <665fa76f-3a19-414b-8524-c2a5bfa8b21b@googlegroups.com>
References <9d0d46e5-b579-4edc-be34-0aa8798b66f8@googlegroups.com> <mailman.1000.1366753795.3114.python-list@python.org> <665fa76f-3a19-414b-8524-c2a5bfa8b21b@googlegroups.com>
Date Tue, 23 Apr 2013 15:34:56 -0700
Subject Re: Reading a CSV file
From Dan Stromberg <drsalists@gmail.com>
To Ana Dionísio <anadionisio257@gmail.com>
Content-Type multipart/alternative; boundary=90e6ba308f827ecae104db0ecb69
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.1005.1366756987.3114.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366756987 news.xs4all.nl 2298 [2001:888:2000:d::a6]:41705
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44231

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Apr 23, 2013 at 2:58 PM, Ana Dionísio <anadionisio257@gmail.com>wrote:

> Thank you, but can you explain it a little better? I am just starting in
> python and I don't think I understood how to apply your awnser
> --
> http://mail.python.org/mailman/listinfo/python-list
>

#!/usr/local/pypy-1.9/bin/pypy

import csv

def main():
    with open('test.csv', 'r') as file_:
        for row in csv.reader(file_, delimiter="|"):
            print row

main()

# Example input:
# abc|def|ghi
# jkl|mno|pqr

In this way, you get one row at a time, instead of all rows at once.

HTH

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


Thread

Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 14:39 -0700
  Re: Reading a CSV file Dan Stromberg <drsalists@gmail.com> - 2013-04-23 14:49 -0700
    Re: Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 14:58 -0700
      Re: Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 15:40 -0700
        Re: Reading a CSV file Fábio Santos <fabiosantosart@gmail.com> - 2013-04-24 00:30 +0100
        Re: Reading a CSV file Dave Angel <davea@davea.name> - 2013-04-23 23:18 -0400
      Re: Reading a CSV file Dan Stromberg <drsalists@gmail.com> - 2013-04-23 15:34 -0700

csiph-web