Some pointers with textscan?

1 次查看(过去 30 天)
Jesse
Jesse 2013-4-3
评论: Jesse 2013-10-7
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!

采纳的回答

Jesse
Jesse 2013-4-3
Disregard. I went about it another way without MATLAB.
  2 个评论
ww
ww 2013-5-23
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 2013-10-7
Shinobue - just saw your post months later. Please re-post if you are interested in finding out more about my solution.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by