How to combine multiple text file into 1 excel file?
6 views (last 30 days)
Show older comments
The codes below gave me a folder (f) of nested cell arrays that are not of equal size, as such I was not able to write from there. I needed all the data to append into 1 sheet.
[filename folder] = uigetfile('*.txt', 'Please select data file', 'MultiSelect', 'on');
for n = 1:size(filename,2) directory = strcat (folder, filename{1,n});
fid = fopen(directory); data = testscan(fid, '%f%s%f%f%f%f%f%f%f%f%f%f%f', 'delimiter', '\t', 'headerlines',1);
fclose(fid);
a = regexp(filename, '_', 'split');
data1 = [a{1,n}{1,2} data];
if n>1 f = [f;data1];
else f = data1;
end
end
f =
'P1Blue' [1455x1 double] {1455x1 cell} [1455x1 double] [1455x1 double] ......
'P1Blue' [993x1 double] {993x1 cell} [993x1 double] [993x1 double] ......
..... and so on for 300 over files...
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!