How do i convert my text file into a column array with the same format as it is in the text file ?

2 views (last 30 days)
I have a text file (attached with the question)i want to convert into an array (a column wise array) .I am not able to get the required result .
Whenever i am textscan or fscanf its converting the file into a huge line with characters ,hence not converting it into an array.I want to each line as a row in the array.
I will attach the code i wrote :
fid = fopen('TestLists.txt')
u = fscanf(fid,'%s');
Kindly find the Text file attached.

Accepted Answer

KSSV
KSSV on 16 Apr 2019
fid = fopen('TestLists.txt','r') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
S{1} % first line
S{3} % third line....

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!