How to read multiple file .txt by using readtable?

4 visualizaciones (últimos 30 días)
Mohamad Khairul Ikhwan Zulkarnain
Mohamad Khairul Ikhwan Zulkarnain el 4 de Jun. de 2018
Respondida: KSSV el 4 de Jun. de 2018
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?

Respuesta aceptada

KSSV
KSSV el 4 de Jun. de 2018
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) ;

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by