How do I create cell/struct array with the specific lines taken from a text file?
Show older comments
this is the code that i currently working with:
% open the file
fid = fopen('images_list1.txt');
% initialize a lineNumer
lineNum = 0;
% keep reading the file
while 1;
% get a line of text
tline = fgetl(fid); lineNum = lineNum + 1;
% exit if the line is empty
if tline == -1;
break;
end
% check modulus of lineNum for every 2nd and 11th line
if rem(lineNum,13) == 2;
tline_2nd = tline;
%disp(tline);
elseif rem(lineNum,13) == 11;
tline_11th = tline;
%disp(tline);
end
end
May I know how do I create cell/struct arrays with the every two lines I have extracted from my text file. For the first line, I'm extracting the image name with a format of "12345678.jpg" and for the second line, i'm extracting the no. of likes, which i would want it to be in a matrix if it is possible. Much help needed.. thanks!
2 Comments
Stephen23
on 28 Oct 2015
Can you upload the data file please. It is useful for us to try code on. You can upload a file by clicking the paperclip button and then both the Choose file and Attach file buttons.
Josephine Ng
on 28 Oct 2015
Accepted Answer
More Answers (0)
Categories
Find more on Workspace Variables and MAT 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!