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


Groups > comp.lang.python > #44223

Re: Reading a CSV file

References <9d0d46e5-b579-4edc-be34-0aa8798b66f8@googlegroups.com>
Date 2013-04-23 14:49 -0700
Subject Re: Reading a CSV file
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1000.1366753795.3114.python-list@python.org> (permalink)

Show all headers | 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