Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

From csv to matrix

I have this file copied of an other question

pcb138,pcb180,pcb52,pcb118,pcb
1.46,0.738,0.532,0.72,19.9959
0.64,0.664,0.03,0.236,6.0996 
3.29,1.15,0.134,1.54,24.9655
3.94,1.33,0.466,1.94,37.4436
3.18,2.14,0.243,1.47,30.183 
2.43,1.3,0.137,1.31,20.8036
3.94,3.49,0.208,0.876,41.3818
3.38,1.04,0.477,2.46,29.478 
2.21,0.966,0.457,1.14,24.2387
2.49,1.59,0.298,1.18,26.3198
0.86,0.395,0.02,0.406,8.591
3.38,1.85,0.539,1.5,36.4229
7.39,4.42,0.707,3.55,66.4108
2.49,1.59,0.298,1.18,26.3198
0.86,0.395,0.02,0.406,8.591
3.38,1.85,0.539,1.5,36.4229
7.39,4.42,0.707,3.55,66.4108

It is saved in a file name pcb.dat. With the following code

import csv                           
file=r'C:\Users\Cyrille\pcb.dat'
reader=csv.reader(open(file))
L=[]
for row in reader:                   
    L.append(row)

show(L)

I can import it in SM. But it's a list composed of strings. And I want a matrix beginning at the second line with Real or Rational numbers. How can I obtain this littel and simple (but absolutely necessary) operation ? Therer is a lot of questions on that subject but I cannot see in the answer the one I am searching.

From csv to matrix

I have this file copied of an other question

pcb138,pcb180,pcb52,pcb118,pcb
1.46,0.738,0.532,0.72,19.9959
0.64,0.664,0.03,0.236,6.0996 
3.29,1.15,0.134,1.54,24.9655
3.94,1.33,0.466,1.94,37.4436
3.18,2.14,0.243,1.47,30.183 
2.43,1.3,0.137,1.31,20.8036
3.94,3.49,0.208,0.876,41.3818
3.38,1.04,0.477,2.46,29.478 
2.21,0.966,0.457,1.14,24.2387
2.49,1.59,0.298,1.18,26.3198
0.86,0.395,0.02,0.406,8.591
3.38,1.85,0.539,1.5,36.4229
7.39,4.42,0.707,3.55,66.4108
2.49,1.59,0.298,1.18,26.3198
0.86,0.395,0.02,0.406,8.591
3.38,1.85,0.539,1.5,36.4229
7.39,4.42,0.707,3.55,66.4108

It is saved in a file name pcb.dat. With the following code

import csv                           
file=r'C:\Users\Cyrille\pcb.dat'
reader=csv.reader(open(file))
L=[]
for row in reader:                   
    L.append(row)

show(L)

I can import it in SM. But it's a list composed of strings. And I want a matrix beginning at the second line with Real or Rational numbers. How can I obtain this littel little and simple (but absolutely necessary) operation ? Therer is a lot of questions on that subject but I cannot see in the answer the one I am searching.