Change path of where the excel files are store and run the code
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Devarshi Patel
il 7 Giu 2019
Risposto: Walter Roberson
il 7 Giu 2019
Hello,
I want the user to run the matlab code from its original directory but running it through the excel files that are located in different directory. For example, if matlab code is stored in C:/user/documents and user selects the excel file to be in C:/user/data/excelfiles, I want the code to go through excelfiles folder and run through those files. I have already tried uigetfile to run the code through user selected path. This is not working out as the code still tries to run through its original directory. (Also excel files are too big to load them to matlab.)
[filenames,path] = uigetfile({'*.csv'},'Select the INPUT DATA FILE(s)','MultiSelect','on');
filename1 = strcat(path,filenames);
Code I am currently using to change the path of the files.
0 Commenti
Risposta accettata
Walter Roberson
il 7 Giu 2019
[filenames, filepath] = uigetfile({'*.csv'},'Select the INPUT DATA FILE(s)','MultiSelect','on');
if isnumeric(filenames); return; end %user cancel
filenames = cellstr(filenames); %in case the user selected only one entry
filenames = fullfile(filepath, filenames);
numfile = length(filenames);
for K = 1 : numfile
thisfile = filenames{K};
thisdatatable = readtable(thisfile);
......
end
0 Commenti
Più risposte (1)
Adam Danz
il 7 Giu 2019
Modificato: Adam Danz
il 7 Giu 2019
This will store the full path to all selected files as strings in a cell array. You can then loop through the cell array to act on each selected file. Is that what you're looking for?
[filenames,path] = uigetfile({'*.csv'},'Select the INPUT DATA FILE(s)','MultiSelect','on');
allFilesFullPath = fullfile(path,filenames);
0 Commenti
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!