Formatting more than 600 table

조회 수: 1 (최근 30일)
Ahmed
Ahmed 2015년 1월 9일
댓글: Ahmed 2015년 1월 21일
I have more than 600 tables each one has a different data. I want To put all the data in the same table (one table). I wonder how can I do that in Matlab. Any help would be greatly appreciated. I will be grateful to you.
  댓글 수: 4
Guillaume
Guillaume 2015년 1월 9일
Are your tables actual matlab tables or just plain text files?
Your naming does not appear to be very consistent. I would have expected the first table to be named either table1 or table001. How is the 10th table named? table010 or table10?
You've not answered whether or not the tables all have the same columns
Ahmed
Ahmed 2015년 1월 9일
The Table is plain text files. It has the same columns. The first table named table01…..tabe10…table11….table600

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2015년 1월 9일
편집: Guillaume 2015년 1월 9일
A simple code (which does not preserve completely the table header):
tabledir = 'C:\wherever\the\files\are\on your\drive';
tablecount = 600; %how however many there are
tableout = 'alltables.txt' %or however you want to name it
tables = cell(tablecount, 1);
%read tables one by one into cell array
for tableidx = 1:tablecount
tablefile = sprintf('table%02d.txt', tableidx);
if ~exist(fullfile(tabledir, tablefile), 'file')
warning('skipping table %s. file does not exist', tablefile);
else
tables{tableidx} = readtable(fullfile(tabledir, tablefile)); %read table
end
end
alltables = vertcat(tables{:}); %concatenate all tables
writetable(alltables, fullfile(tabledir, tableout));
Note, that I've not tested nor debugged it, there may be some small typos, syntax errors.
  댓글 수: 1
Ahmed
Ahmed 2015년 1월 21일
Thank you so much Guillaume. I did some modification on it and it is work well.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by