can not read this file

hi
I have txt file with big size (570 MB). I try to read it
by this code:
f1=fopen('d:\matlab11\bin\test1.txt');
c=textscan(f1,'%d %d %f %s %s');
fclose(f1);
c1=c{1}; c2=c{2};c3=c{3};c4=c{4};c5=c{5};
u_user=unique(c1);
u_movie=unique(c2);
%%%%%%%%%%%%%%%%
but I did not get the sme data and not all.
I tried with small part from the same data , I got correct data.
this is the sample:
852910 47995 5 2008-08-16 00:00:00
852910 49280 4.5 2008-05-05 00:00:00
852910 49325 4.5 2008-06-10 00:00:00
852910 48116 5 2008-01-12 00:00:00
how I can read this big size file?
thanks in advance

댓글 수: 1

Oleg Komarov
Oleg Komarov 2012년 4월 24일
Then the file could be corrupt, check it from where you stopped reading it.

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

답변 (1개)

Ken Atwell
Ken Atwell 2012년 4월 24일

0 개 추천

textscan can return a second output, "pos", which will return the position that textscan stopped at if an error occurred (which seems to be the case here). You can also determine where the error is by the length of what textscan managed return in the first output. If you text file is, say, 10000 row long and c{1} is only 1234 rows long, your error is around that row.

댓글 수: 1

huda nawaf
huda nawaf 2012년 4월 25일
thanks,
in fact it is not error but when need see c1
i get Empty matrix: 0-by-1
the no. of rows is 8196077.
I would like to say that my code can read the same file (the same no. of rows) but with three columns correctly .why when be five columns with same no. of rows get empty matrix?

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

카테고리

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

태그

질문:

2012년 4월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by