Borrar filtros
Borrar filtros

Import multiple .txt files

3 visualizaciones (últimos 30 días)
SAZZAD HOSSAIN
SAZZAD HOSSAIN el 29 de Jul. de 2021
Comentada: Chunru el 30 de Jul. de 2021
Hi,
I have some text files that I want to import all at once. I am using the following code to try to import them.
files = dir(fullfile(roothpath, '*.txt'));
file_paths = fullfile({files.folder}, {files.name});
for i = 1 : numel(file_paths)
data = textread(file_paths{i}, '');
end
However, the text files have headers and I am having trouble removing them. So my question is what can I do to import them with commands to remove the header and import all the files.
Thanks.

Respuestas (1)

Chunru
Chunru el 29 de Jul. de 2021
Use "headerlines" parameter to ignore the header lines:
data = textread(file_paths{i}, format, 'headerlines', headlineNum);
  2 comentarios
SAZZAD HOSSAIN
SAZZAD HOSSAIN el 29 de Jul. de 2021
Hi Chunru,
Thanks for the suggestion. I tried the command line and its saying "too many output arguments". I am using Matlab 2018a if that matters at all.
Chunru
Chunru el 30 de Jul. de 2021
Post a small fraction of data file.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import and Export 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