Reading only Certain Columns from .CSV
28 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to read in the 1st and 3rd columns of data from a file.
I know this code shows the 2nd and 3rd:
M = csvread('filename.csv', 2, 2)
How do I skip the 2nd column and just display the 1st and 3rd?
0 件のコメント
回答 (1 件)
Walter Roberson
2019 年 3 月 20 日
編集済み: Walter Roberson
2019 年 3 月 20 日
That cannot be done with csvread() or dlmread().
With textscan() you would use a format specification of '%f %*f %f %*[^\n]' . You would probably use cell2mat() around the result of the textscan() call.
With readtable() the way to proceed would be to use detectImportOptions (new as of R2016b). You might have to give the option 'ReadVariableNames', false . Assign the result to a variable, and set the SelectedVariableNames property of the object to [1 3]. Then use readtable() on the .csv file, passing in that options object.
18 件のコメント
Walter Roberson
2019 年 4 月 3 日
What would it mean to use a greater than operator with those text timestamps ?
If you want to test the sensor values you can extract them from the table:
mask = t{:,4} > 20;
which could, for example, be used in the context:
t(t{:.4}>20, [2 4])
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!