How to import data with different structures

2 次查看(过去 30 天)
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

回答(1 个)

Loen
Loen 2013-11-18
nobody?

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by