フィルターのクリア

How can I skip lines when reading from a text file

77 ビュー (過去 30 日間)
Ahmed
Ahmed 2013 年 7 月 19 日
Hello All,
I have a text file with the extension .rep
I need to skip the first 36 lines and then start reading numeric data.
How can I do this?
Thanks alot,
Ahmed

採用された回答

David Sanchez
David Sanchez 2013 年 7 月 19 日
You could try the built-in function fgets:
fid = fopen('my_file.m');
% read the first 36 lines and do nothing to them
for k=1:36
tline = fgets(fid);
end
% next reading will be on 37th line.
% display form 37th line forward:
while ischar(tline)
disp(tline)
tline = fgets(fid);
end
fclose(fid)
For more details, type:
help fgets
doc fgets
  1 件のコメント
Berenice Cervantes
Berenice Cervantes 2020 年 5 月 6 日
omg, this works beautifully!! Thank you :)

サインインしてコメントする。

その他の回答 (1 件)

YUMIN HO
YUMIN HO 2019 年 6 月 14 日
thank you for the answer

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by