CSV to matrix array
Dave Angel
davea at davea.name
Fri Apr 12 13:46:22 EDT 2013
On 04/12/2013 01:29 PM, Ana Dionísio wrote:
> That only puts the data in one column, I wanted to separate it.
>
> For example:
> data in csv file:
>
> 1 2 3 4 5
> 7 8 9 10 11
> a b c d e
>
> I wanted an array where I could pick an element in each position. In the case above if I did print array[0][3] it would pick 4
>
I know nothing about numpy.
How about something like:
import csv
myreader = csv.reader(....)
mylist = list(myreader)
Presumably you can fill in the details. Anyway, I think this will give
you a list of lists, and perhaps you can convert that to a numpy array,
if you really need one of those.
--
DaveA
More information about the Python-list
mailing list