How to extract time and date data from huge text file?
Show older comments
Dear all,
I am working on one big data science project. I need to extract data from one text file into separate columns of Matlab variable. I have attached smaller portion of the data along with this message. Can anybody please tell me where am I going wrong in my code for extracting data from text file? Thank you in advance, My MATLAB code is as follows:
fid = fopen('Nikhil.txt','r');
iread=0; icount = 0;
while(iread~=1)
icount=icount+1;
tline=fgetl(fid);
corr1=strfind(tline,'Date;Time;Global_active_power;Global_reactive_power;Voltage;Global_intensity;Sub_metering_1;Sub_metering_2;Sub_metering_3');
if(corr1~=0)
sizeA= [9 Inf];
[strdat, count]=fscanf(fid,['%D %D %g %g %g %g %g %g %g'],sizeA);
iread=iread+1;
end;
end;
%strdat=strdat';
fclose(fid);
n=length(strdat);
strdat
Accepted Answer
More Answers (0)
Categories
Find more on Text Files 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!