CSVファイルから特定の列のデータのみ取得する方法
50 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Matlab2018aを使用しています。 メモリ節約のため、textscanで600000行のCSVデータを20000行ずつ読み込み、 3列目のデータの20000個の平均を算出したいと思っています。 下記のようなプログラムを書いたのですがループが入れ子になっており 速度が遅いです。 data{1}は20000x1 のcell型配列になっています。 data{1}から3列目のデータを20000個素早く取得する方法はないでしょうか。
for i=1:30
data = textscan(fileID, '%s', 20000);
% 20000回ループ
for j=1:length(data{1})
% CSVデータの3列目のみを2000個取得
end
% 取得した2000個のデータを平均する処理
end
close(fileID);
0 commentaires
Réponse acceptée
mizu
le 9 Nov 2018
datastore で、読み込む前に列を絞ってはいかがでしょうか.
ヘルプの例にあるように、SelectedVariablename で読み込む列を指定することができます。
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!