Reading few lines from a text file

I have a text file and I want to read first 10 lines from that file.I tried scantext but not successful.
Can anyone suggest?

댓글 수: 5

John Petersen
John Petersen 2012년 11월 29일
how about a sample of your text file?
Shalini
Shalini 2012년 11월 29일
It is like:
1cccc43 2021 zzvbbb 3cccc43 2051 aggdef 1ddcc43 2775 abcdef 4chhc43 2021 abghef
It has fot several millions of lines and hance I cannot open in xls (lines get truncated beyond a certain limit) so I want to convert it into a text file with fewer lines so that I open in excel
Jan
Jan 2012년 11월 30일
편집: Jan 2012년 11월 30일
[MOVED from answer section] Shalini wrote:
can anyone pls help?
Jan
Jan 2012년 11월 30일
[MOVED from answer section] Vishal Rane wrote:
Post your comments in the comments sections only. Not many of us bother opening a thread that already has a couple of answers.
Now for your query, refer these functions and examples, Low Level File IO
Comment back in case of any doubts.
Jan
Jan 2012년 11월 30일
@Shalini: Whenever you post the term "I tried...", post the corresponding code and the occurring problems also. Otherwise we cannot give an advice for improvements.

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

답변 (1개)

Jan
Jan 2012년 11월 30일
편집: Jan 2012년 11월 30일

0 개 추천

  • fopen() to open the file (a test for success is strongly recommended)
  • Data = cell(1, 10): Pre-allocate the output
  • for loop from 1 to 10
  • fgets() to read one line, store it in Data cell.
  • end
  • fclose() to close the file

카테고리

도움말 센터File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

질문:

2012년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by