How to select one column of data from a csv file containing headers and strings?
Ältere Kommentare anzeigen
The csv files in question each contain five columns, and an unknown number of rows:

Suppose a file has N rows. I want to select all the data from B2 to BN and save them into a table.
I tried this:
table_x = csvread('filename.csv', 1, 1, [1, 1, Inf, 1]);
That doesn't work. It wants me specify the number of rows, which I don't know. I guess can't use csvread because I don't know what N is and because the file contains non-numeric data.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 28 Jul. 2015
fmt = '%*f%f%*f%*f%*[\n]';
fid = fopen('filename.csv', 'rt');
datacell = textscan(fid, fmt, 'Delimiter', ',', 'HeaderLines', 1);
fclose(fid);
table_x = datacell{1};
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!