필터 지우기
필터 지우기

How to read multiple file .txt by using readtable?

조회 수: 3 (최근 30일)
Mohamad Khairul Ikhwan Zulkarnain
답변: KSSV 2018년 6월 4일
I got more than three file to read but if Im going to readtable every single file its going to takes time. Is there any method for me to read all this file in one go and save it in one file?

채택된 답변

KSSV
KSSV 2018년 6월 4일
files = dir('*.txt') ;
N = length(files) ;
SS = cell(N,1) ;
fid0 = fopen('myfile.txt','w');
for i = 1:N
fid = fopen(files(i).name,'r') ;
S = textscan(fid,'%s','delimiter','\n') ;
SS = S{1} ;
fclose(fid) ;
for j = 1:numel(SS)
fprintf(fid0,'%s\n',SS{j}) ;
end
end
fclose(fid0) ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by