Delete lines from text file
이전 댓글 표시
How can I delete all the lines form a text file after the line number x and store it in another test file?
채택된 답변
추가 답변 (1개)
dpb
2013년 8월 29일
0 개 추천
Read line 1:x from 1 and copy to the second. Close the second. Done.
Alternatively, rather than line-by-line, read the whole file if it's small enough to fit in memory relatively easily and if x is a sizable fraction of the total number of lines. Then just save data(1:x,:) to the new file.
That's the thing about sequential files---they're, well, 'sequential'.
카테고리
도움말 센터 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!