MATLAB Answers

read multiple csv files from different subfolders

23 views (last 30 days)
Jiaqi Wang
Jiaqi Wang on 17 Oct 2019
Answered: prasanth s on 17 Oct 2019
I have a folder, "Raw data", which contains subfolders for subjects 005 - 016. In each subfolder, I want to choose a subsubfolder, "A". In "A" folder, there are 23 .csv files. How can I read them as individual file (without merging them) at once, maybe using a loop function of other methods?

  0 Comments

Sign in to comment.

Answers (1)

prasanth s
prasanth s on 17 Oct 2019
Use 'dir' function to get the directory and file list of any folder. e.g
D=dir('Raw data');
output 'D' is an structure array contains all foldernames. Use the for loop to read each foldername. Again use the dir to get the subfolders.
then use following code format to get all csv filenames
A=dir('myfolder\*.csv');
then get the filenames from 'A' and use 'csvread' function to tead each csv files

  0 Comments

Sign in to comment.


Translated by