Import from data from messy text file
Mostrar comentarios más antiguos
Hi, I have looked through the questions and answers that are already available for this topic but wasn't able to apply those to my situation.
For the attached file, I need to extract the data for each "Specimen." The data that i need are the three columns corresponding to the 500+ rows for each specimen. If possible, I would like to save it in to different arrays. One for each specimen.
Respuesta aceptada
Más respuestas (1)
Shameer Parmar
el 28 de Jul. de 2016
Here is that can help you..
Data = textread('SAMPLE_DATA.txt', '%s', 'delimiter', '');
count=1;
newData = {};
for i=1:length(Data)
if ~isempty(strfind(Data{i},','))
newData{count,1} = Data{i};
count=count+1;
end
end
count1=1;
count2=0;
Specimen = {};
for i=1:length(newData)
linedata = newData{i};
if ~isempty(strfind(linedata(1:2),'1,'))
count2=count2+1;
count1=1;
Specimen{count1,count2} = linedata;
else
count1=count1+1;
Specimen{count1,count2} = linedata;
end
end
to check the output
type
Specimen(:,2);
Categorías
Más información sobre Text Data Preparation en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!