Scan CSV file and saving it into an array

Ana Dionísio anadionisio257 at gmail.com
Wed Apr 24 19:01:01 EDT 2013


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)
for row in p:
       if row[0]=="200":
          a=row
          break
print a



More information about the Python-list mailing list