Importing folder of .csv files and saving them as variables with different names.
Mostra commenti meno recenti
I have a folder of 90 .csv files and i want to bring them all into matlab one after the other and save them as vairables and each one have a different name.
Can somebody give me some template code to do this please.
Thanks
Risposte (1)
Azzi Abdelmalek
il 14 Mag 2014
d='E:\matlab' % your folder
f=dir([d '\*.csv'])
for k=1:numel(f)
data{k}=xlsread(f{k}.name);
end
If you want the data from the third file:
data{3}
Do not use a variable for each file.
6 Commenti
BOB
il 14 Mag 2014
Image Analyst
il 15 Mag 2014
Bits? Like 32 bits or 64 bits? No. You can have the directory be wherever you want it (that you have permission to write to).
BOB
il 15 Mag 2014
BOB
il 16 Mag 2014
Chugh
il 23 Mag 2018
Hi, Did you get an answer for your question? I am also searching for the same.
Karen DSouza
il 17 Lug 2018
Modificato: Karen DSouza
il 17 Lug 2018
What would be the easiest way about horizontally concatenating data tables saved in a cell array like above? I don't want to hard code it because the length of the cell array is subject to change. Essentially from above I have a resulting 1 * 8 cell array with tables of varying # of cols but same amount of rows. I wish to combine all the data from these files by the function join using the column "ID".
Thanks!
Categorie
Scopri di più su Variables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!