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


Groups > comp.lang.python > #44223

Re: Reading a CSV file

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news.astraweb.com!border5.a.newsrouter.astraweb.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'error:': 0.07; 'subject:file': 0.07; 'iterate': 0.09; 'rows': 0.09; 'cc:addr :python-list': 0.11; '"n"': 0.16; '23,': 0.16; 'columns': 0.16; 'csv': 0.16; 'once.': 0.16; 'subject:CSV': 0.16; 'subject:Reading': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'documented': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'array': 0.29; 'message-id:@mail.gmail.com': 0.30; 'prints': 0.31; 'file': 0.32; 'url:python': 0.33; 'at:': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'too': 0.37; 'skip:& 10': 0.38; 'url:library': 0.38; 'pm,': 0.38; '8bit%:6': 0.40; 'how': 0.40; 'read': 0.60; 'url:3': 0.61; 'skip:* 10': 0.61; 'save': 0.62; 'to:addr:gmail.com': 0.65; 'to:charset:iso-8859-1': 0.74; 'ana': 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=XWM6n5TkH7UyUNP24LcCrJQm8ExSnEqu0m9PxO2fyDY=; b=Uiq4u0YQHsWggCPae5WR2qTbCihsVD+y4B3RqQT9d12/bIUyzteMeZXLkLIzUewbVN /ce47pL3L3mFlpTpYzSOccFeuf1LZ6ikHZAJuw0aDVsgmbmoVLovCV4kX4drW2qluU8x DT9V6HYes0C4mgtRD0JAOE+BYNNrMaudjT0R0HVpTBNdCGYNBB8WEpH+zVAkSN7rwrm5 u/yV3jBHDxowmdB/W4Ufn+8raTyxAgsMFITL7uOpTHCi/0CENY1ESfC3wXZOmqVYcOU/ iXuTQRDrhiS9BulhLvpHdo/DOQKKWYpPjUbvgMz3SfAvdDw8jFAaPrfBJ6nLgwKM0iYQ adnQ==
MIME-Version 1.0
X-Received by 10.224.17.72 with SMTP id r8mr27411219qaa.48.1366753787488; Tue, 23 Apr 2013 14:49:47 -0700 (PDT)
In-Reply-To <9d0d46e5-b579-4edc-be34-0aa8798b66f8@googlegroups.com>
References <9d0d46e5-b579-4edc-be34-0aa8798b66f8@googlegroups.com>
Date Tue, 23 Apr 2013 14:49:47 -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=14dae93995f5ffae8a04db0e2939
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.1000.1366753795.3114.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366753795 news.xs4all.nl 2177 [2001:888:2000:d::a6]:37711
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44223

Show key headers only | View raw


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

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

> Hello!
>
> I need to read a CSV file that has "n" rows and "m" columns and if a
> certain condition is met, for exameple n==200, it prints all the columns in
> that row. How can I do this? I tried to save all the data in a
> multi-dimensional array but I get this error:
>
> "ValueError: array is too big


Use:
csv.reader(*csvfile*, *dialect='excel'*,
***fmtparams*)¶<http://docs.python.org/2/library/csv.html#csv.reader>

This will allow you to iterate over the values, instead of reading them all
into memory at once.

csv.reader is documented at:

http://docs.python.org/3/library/csv.html

http://docs.python.org/2/library/csv.html

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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