How to import data with different structures

1 view (last 30 days)
Loen
Loen on 18 Nov 2013
Answered: Loen on 18 Nov 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

Answers (1)

Loen
Loen on 18 Nov 2013
nobody?

Categories

Find more on Data Import and Analysis 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!