MATLAB: Process a sequence of csv files in a folder.

csvexcelfolderimportoutputsequence

I need to import the data seen in the image below, The second image represents data from 1 csv file
The code below was taken from
and successfully reads the names of the files but only saves the data from the last file.
*I need to combine all the files that are from the same day and plot the temperature,voltage and strain from that certain day against the time recorded. each file represents 2-5 minutes of data, the name of the file contains the date and the time of reading.
The folder contains 24 days in total, each day with different amount of hours recorded.
% Specify the folder where the files live.
myFolder = 'C:\Users\YOU215\Desktop\liverpool bridge\Temp';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.csv'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
end

Best Answer

After the fprintf saying which file you are processing, you need to readtable(fullFileName) and save the result, such as
name_parts = strsplit(fullFileName, '_');
file_date{k} = [name_parts{6:8}];
data_table{k} = readtable(fullFileName, 'HeaderLines', 3);
Once you have of the data read in you can compare the file_date information to figure out which entries to group
[unique_dates, ~, uidx] = unique(file_date, 'stable');
Now the entries in uidx will be from 1 : length(unique_dates), and the K'th file read corresponds to unique_dates(uidx(K)) and all of the uidx entries that are the same belong to the same day.