Import multiple .txt files by dates from user input
Mostra commenti meno recenti
Hi!
I have a folder with appr. 47000 txt-files. I would like to open only a few of them. I attach a screenshot of the folder and the filenames.
I have created an app with appdesigner where the user can select startdate/starttime and enddate/endtime.
Now I would like to open only the .txtfiles relevant to the user input.
What would be the best way to approach this?
I have been trying something like this:
foldername='%This is the name of my folder'; %adds the path of the archive
filepattern=fullfile(foldername, '*.txt);
D = dir(filepattern);
This would give me a struct with all .txt files.
What I would like to do is to select only the files matching periodDTstr below:
period = [tstart:tend]; %tstart and tend is datetime values from app
periodstr=datestr(period,'yyyymm');
periodstrday=datestr(period,'yyyymmdd');
w=unique(periodstr,'rows');
numfiles=length(w(:,1));
Starttime=datestr(timein,'HHMM'); %timein is user input from app
Stoptime=datestr(timeout,'HHMM'); %timeout is user input from app
StartDT=strcat(periodstrday(1,:),Starttime);
StopDT=strcat(periodstrday(end,:),Stoptime);
StartDTstr=datetime(StartDT,'InputFormat','yyyyMMddHHmm');
StopDTstr=datetime(StopDT,'InputFormat','yyyyMMddHHmm');
periodDT=[StartDTstr:hours:StopDTstr];
periodDTstr=datestr(periodDT,'yyyymmddHH');
Could you please help me with this?
Best regards
/Linus
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Calendar in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!