필터 지우기
필터 지우기

Delete rows in single .txt files

조회 수: 2 (최근 30일)
julro
julro 2014년 7월 5일
댓글: Image Analyst 2014년 7월 6일
Hey,
I have 30 .txt files where I would like to delete always the first three rows before creating one file for all 30 files...?
Thanks already!
Best!

답변 (1개)

Image Analyst
Image Analyst 2014년 7월 5일
Before the loop open a file for output.
fOutput = fopen('output.txt, 'wt');
Then go into the loop opening the files (as per the FAQ). Call fgetl() three times and throw away/ignore the text you get back. Then continue on to the end of the file transferring the stuff to the output file
textLine = fgetl(fInput);
fprintf(fOutput, '%s\n', textLine);
Finally when all lines have been transferred, call fclose(fInput). Then when the loop is done, call fcope(fOputput). It's really easy - give it a try.
Sounds a little like homework, so I didn't just do the whole thing for you, even though it's trivial.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 7월 6일
julro, were you able to complete the task using the method I outlined???

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by