How can i find specific data from a large no. of csv file?

1 回表示 (過去 30 日間)
Deepesh Kumar Gupta
Deepesh Kumar Gupta 2022 年 3 月 31 日
コメント済み: KSSV 2022 年 4 月 1 日
i have 1080 csv file named 1_1,1_2,...1_36, 2_1, 2_2,...2_36........30_1, 30_2,30_36, each file have different no. of rows with same no. of column,these files have x, y ,z and temperature values. I have one csv file named Data.csv having 68 combination of x ,y and z values , now i want to extract all 68 temperature values for each x , y and z points of Data.csv for each file into a single matrix of [68*1080]. How can i do this ,please help me with matlab code.
i am attaching Data.scv and one 1_1.csv for reference.

回答 (1 件)

KSSV
KSSV 2022 年 3 月 31 日
T = readtable('Data.csv') ;
csvFiles = dir('*.csv') ; % otherfiles in a folder. Keep Data.csv seperatly
N = length(csvFiles) ;
M = size(T,1) ;
iwant = zeros(M,N) ;
for i = 1:N
Ti = readtable(csvFiles(i).name) ;
idx = knnsearch([Ti.(1) Ti.(2)],[T.(1) T.(2)]) ;
iwant(:,i) = Ti.(3)(idx) ;
end
  4 件のコメント
Deepesh Kumar Gupta
Deepesh Kumar Gupta 2022 年 3 月 31 日
@KSSV thanks for your answer , but i am not getting the temperature values for each set of x,y and z points of Data.csv.
i am attaching the matrix ,that i have obtained from the above code.
KSSV
KSSV 2022 年 4 月 1 日
I am getting the values from the csv files which you have uploaded.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by