Some pointers with textscan?

1 view (last 30 days)
Jesse
Jesse on 3 Apr 2013
Commented: Jesse on 7 Oct 2013
Hi,
I've been trying to import a data file (a nasty one) and convert it to rows can columns. But I feel that textscan dumps my data into one big column, which is what I don't want.
A snippet of my data file is as follows:
'GP31M V1.25 031115B'
'L 2 BH1 W M0.0'
'T 03/11/2013 15:49:08'
'@,235051.00,7119.963154,N,15640.819460,W,2,09,1.0,15:50:38.91'
'SH10 1.000 222.750 20.478 15:50:39.19'
'@,235052.00,7119.963153,N,15640.819483,W,2,09,1.0,15:50:39.74'
'@,235103.00,7119.962785,N,15640.820648,W,2,09,1.0,15:50:50.78'
'SH10 2.000 222.250 20.478 15:50:51.49'
'@,235104.00,7119.962781,N,15640.820656,W,2,09,1.0,15:50:51.76'
'@,235111.00,7119.962351,N,15640.821861,W,2,09,1.0,15:50:58.68'
'SH10 3.000 221.250 20.478 15:50:59.51'
'@,235112.00,7119.962354,N,15640.821875,W,2,09,1.0,15:50:59.78'
where the first three lines are a header, and if you look at the next three lines, the data in the second line is what I need in 5 separate columns, and the file repeats every three lines, where the data I need occurs every second line.
I'm following this approach (it's not done) according to example code (and I hope this posts correctly):
clc
clear all
close all
%importing in the data - raw read
fileID = fopen('031115B.G31', 'r');
Data = textscan(fileID, '%s', 3, 'delimiter', '\n');
Intro=Data{1};
disp(Intro);
Block=1;
while (~feof(fileID)) % For each block:
sprintf('Block: %s', num2str(Block)); % Display block number
InputText=textscan(fileID,'%s',1,'delimiter','\n'); % Read header line
HeaderLines{Block,1}=InputText{1};
disp(HeaderLines{Block});
end
fclose(fileID);
Is there something that I can try to strip down the data file and break the data down into separate columns as discussed above?
Thanks!

Accepted Answer

Jesse
Jesse on 3 Apr 2013
Disregard. I went about it another way without MATLAB.
  2 Comments
ww
ww on 23 May 2013
Could you perhaps share your solution? I have a similar problem: the odd rows are the time stamp and the even rows are the data.
Thanks
Jesse
Jesse on 7 Oct 2013
Shinobue - just saw your post months later. Please re-post if you are interested in finding out more about my solution.

Sign in to comment.

More Answers (0)

Categories

Find more on Large Files and Big Data 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!