3

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? :-)

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Johnny Doe
  • 45
  • 4

2 Answers2

4

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
Nemesis
  • 2,324
  • 13
  • 23
3

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
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147