Effacer les filtres
Effacer les filtres

Given i have multiple csv files in a folder, how can i access it and read them?

12 vues (au cours des 30 derniers jours)
Hi
T1=xlsread('file1.csv');
T2=xlsread('file2.csv');
...
How can i access each file in my folder and process them eventually?

Réponse acceptée

Lukas Bystricky
Lukas Bystricky le 4 Août 2015
Try something like this
files = dir('*.csv');
num_files = length(files);
results = cell(length(files), 1);
for i = 1:num_files
results{i} = xlsread(files(i).name);
end
  3 commentaires
Travis Briles
Travis Briles le 10 Mai 2021
How do you do this if the files are stored in sub-folders within the main directory?
mahmoud abd elrehem
mahmoud abd elrehem le 29 Août 2022
You should select the path by command "pwd"

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by