Open up and load multiple files in Scilab with the extension .csv

StackOverflow https://stackoverflow.com/questions/22841298

  •  27-06-2023
  •  | 
  •  

سؤال

I need a way to open all the files in a folder, regardless of the filename. All the files have a .csv extension.

هل كانت مفيدة؟

المحلول

You could use listfiles and csvRead like this

function doSomethingWithCSVdata(CSV_data)
    disp(CSV_data);
endfunction

csv_files = listfiles('*.csv');

for i=1:size(csv_files,1)

    disp('Opening file: '+csv_files(i))
    csvData = csvRead(csv_files(i),ascii(9), [], 'string');

    doSomethingWithCSVdata(csvData);
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top