Filter löschen
Filter löschen

CSVread does not read file with offset

5 Ansichten (letzte 30 Tage)
rough93
rough93 am 13 Jul. 2020
Kommentiert: rough93 am 13 Jul. 2020
I'm attempting to read a csv file with offset but for some reason I get the following error:
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 7) ==> Y\n
My file looks like the following:
I'm attempting to use
M = csvread('filename.csv',1,2,[1,5,5,4])
If you can point out where I'm going wrong (and why the error points to Y\n) please let me know. Thanks.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Jul. 2020
csvread() can only skip complete leading text lines, and leading text columns. It is not able to skip trailing text columns even if you give a range parameter.
You should switch to readtable()
  1 Kommentar
rough93
rough93 am 13 Jul. 2020
Thanks Walter, right as usual.
For future reference for other users, you can use the following code with readtable to cut out just the values you want from an alphanumeric table:
T = readtable('filename.csv');
T = T(1:25,3:6); % row boundary, column boundary
A = T{:,:}; % converts selection to matrix (numerical)
Of course, that code came from Walter in another answer...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by