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


Groups > comp.lang.python > #44306

Re: Scan CSV file and saving it into an array

References <1533da3c-a297-41a0-a575-968a86120a5b@googlegroups.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date 2013-04-25 01:21 +0100
Subject Re: Scan CSV file and saving it into an array
Newsgroups comp.lang.python
Message-ID <mailman.1042.1366849332.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 25 April 2013 00:01, Ana Dionísio <anadionisio257@gmail.com> wrote:
> Hello!
>
> I have this script that scans a csv file and if the value in the first column == 200 it saves that row into an array.
>
> The problem is, I need to save that row and the next 10 rows in that same array. What can I add to the script so it does that? I tried to do for row in len(10): but I get an error.
>
>
> p = csv.reader(open('file.csv'), delimiter=';')
> a=[0]*2881
> a = numpy.array(a, dtype=dict)

You shouldn't be using a numpy array for this; use a list instead. I
suggest that you have a go at the Python tutorial and avoid using
numpy until you are more confident with the basics of Python itself.

The tutorial (for Python 2) is here:
http://docs.python.org/2/tutorial/


Oscar

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


Thread

Scan CSV file and saving it into an array Ana Dionísio <anadionisio257@gmail.com> - 2013-04-24 16:01 -0700
  Re: Scan CSV file and saving it into an array "Rhodri James" <rhodri@wildebst.demon.co.uk> - 2013-04-25 00:21 +0100
    Re: Scan CSV file and saving it into an array Dave Angel <davea@davea.name> - 2013-04-24 19:47 -0400
  Re: Scan CSV file and saving it into an array Dave Angel <davea@davea.name> - 2013-04-24 20:01 -0400
  Re: Scan CSV file and saving it into an array Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-25 01:21 +0100

csiph-web