Reputation: 45
I have a .csv
file with the following 'configuration'
'string', 'string', 'string', 'string', 'string'
'string', 'string', 21, 89, 67
'string', 'string', 45, 12, -16
'string', 'string', 78, 56, 45
'string', 'string', 23, 65, 90
'string', 'string', 43, 34, 75
I would like to ignore the first two columns and the first row, and import the numbers to a matrix.
I have tried using textscan
, but without luck. Any experts? :-)
Upvotes: 3
Views: 507
Reputation: 2334
Try dlmread
. You can specify the row and column to start the import.
data = dlmread('test.txt',',',1,2)
data =
21 89 67
45 12 -16
78 56 45
23 65 90
43 34 75
Upvotes: 4
Reputation: 112679
Use importdata
:
x = importdata('filename.csv');
This gives an x
struct with data
and textdata
fields:
>> x
x =
data: [5x3 double]
textdata: {6x5 cell}
To get only the numeric values, use
x_numeric = x.data;
In your example, this gives
x_numeric =
21 89 67
45 12 -16
78 56 45
23 65 90
43 34 75
Upvotes: 3