read formated text file

조회 수: 2(최근 30일)
Luis Isaac
Luis Isaac 2021년 4월 13일
편집: Abhishek Gupta 2021년 4월 16일
I have a very large file(250 MB aporx)
The first 8 lines are administrative information and the rest are the data itself
The data is well formated, and in fact without the first lines the whole file can be read with textscan(line, '%f %f %f %f)
Is it posible to applied the textscan intruction to a part of the file, i.e. how to discard the 8 first lines and use textscan (or something similar for the rest)
I've made some programs using for loop and fgets but the program takes some time to load the data becasuse the file is too big
  댓글 수: 1
Mario Malic
Mario Malic 2021년 4월 13일
Check the documentation for the HeaderLines input argument.

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

채택된 답변

Abhishek Gupta
Abhishek Gupta 2021년 4월 16일
편집: Abhishek Gupta 2021년 4월 16일
As per my understanding, you want to read a text file with 8 header lines. You can scan the text as follows: -
fid = fopen('mydata.txt');
data = textscan(fid, '%f %f %f %f', 'headerLines', 8);
For more details, check out the documentation link below: -

추가 답변(0개)


Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by