CSV to matrix array

cantorp at gmail.com cantorp at gmail.com
Sat Apr 13 13:06:15 EDT 2013


Dear Ana,

your example data could be transformed into a matrix with

>>>import csv
>>>rows = csv.reader(open("your_data_file.csv"), delimiter=" ")
>>>array = [row for row in rows]
>>>array[0][3]
4

HTH
Paolo

Am Freitag, 12. April 2013 19:29:05 UTC+2 schrieb Ana Dionísio:
> 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




More information about the Python-list mailing list