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