Ask Your Question

Revision history [back]

Note that csv means coma separated value. Here, you want a semicolon to be used as a delimiter, so you can do:

sage: data=list( csv.reader(open('data.csv','r'), delimiter=';'))
sage: data
[['3', '2'], ['2', '1'], ['1', '0.1'], ['0.01', '-0.9']]

Note that csv means coma separated value. Here, you want a semicolon to be used as a delimiter, so you can do:

sage: data=list( csv.reader(open('data.csv','r'), delimiter=';'))
sage: data
[['3', '2'], ['2', '1'], ['1', '0.1'], ['0.01', '-0.9']]

Note that it is a list of lists of strings, not number. However, the matrix constructor is able to handle this : you can make it a numerical matrix as follows:

sage: matrix(RDF,data)
[ 3.0  2.0]
[ 2.0  1.0]
[ 1.0  0.1]
[0.01 -0.9]