How to import data with different structures

10 visualizaciones (últimos 30 días)
Loen
Loen el 18 de Nov. de 2013
Respondida: Loen el 18 de Nov. de 2013
Hello,
I've a whole bunch of datafiles existing of text and tables. These files are filled automatically with measurement data and because of this the size is different for each file.
I want to import the data to analyze and plot the content of the different tables.
At the moment I use textscan and load the file in one cell...
[name, pathname] = uigetfile('*.log');
filename = cat(2, pathname, name);
delimiter = '\t';
formatSpec = '%s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN, 'ReturnOnError', false);
fclose(fileID);
Data = dataArray{:, 1};
clearvars delimiter formatSpec fileID dataArray ans;
Then find the beginning and end of each table with strcmp
Q = strcmp('qqqqqq', Data);
x = strcmp('xxxxxx', Data);
Then reload the data again with textscan with begin and end row defined as Q and X and load the content of the table into double and cells (depends on the content). This is repeated for all tables .
My question: I'm sure there's an easier and less time-consuming process but I don't know how. Could someone explain to me what's the best way to handle this kind of logfiles
best regards, loen

Respuestas (1)

Loen
Loen el 18 de Nov. de 2013
nobody?

Community Treasure Hunt

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

Start Hunting!

Translated by