How to add dates to a read loop
Mostrar comentarios más antiguos
hi, i have the following loop which reads a lot xls files and stores them in a table. Each file contains hourly data at a specific date starts from 01/01/2012
myFolder = 'C:\Users\...\All';
filePattern = fullfile(myFolder, '*.xls');
theFiles = dir(filePattern);
x={ };
for k = 1 : length(theFiles) ;
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
x{k} = readtable(fullFileName);
end
How can i add an extra column to each table with the date of each file from which the table was created?
For example the third file contains 24 records of the date 03/01/2012
Respuestas (2)
Jose Marques
el 9 de Sept. de 2017
0 votos
It appears you need to concatenate tables; see for example
1 comentario
Ioannis Tsikriteas
el 9 de Sept. de 2017
Peter Perkins
el 14 de Sept. de 2017
0 votos
Create a datetime column vector and assign it to your table.
d = datetime(2012,3,repmat(1,24,1)) % assuming you mean march 1st, not jan 3rd x{k}.Time = d;
Categorías
Más información sobre Manage Products en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!