How to import data and remove headers

Hello,
I am trying to import a log file although I'm having problems running the script due to the headers in the file
EMuJoy --- Joystick movement and emotion measuring
Version 1.0
Date: Wed Jan 09 13:12:16 GMT 2019
TIME,X-COORD,Y-COORD,TRIGGER
*** Music Start ***1547039542802;-0.890625;0.2199004975124379;64
1547039542818;-0.9010416666666666;0.2875621890547264;64
1547039542832;-0.9041666666666667;0.30746268656716413;64
How do I remove the first lines of text so I can just analyse the numbers, and do I need to save a new file before I can import the data?
EDIT: Apologies I'm a bit of a newbie, the original file isn't a text file but text version is attached. My script so far is:
for i = 1:length(DataFolder)
filename = DataFolder(i).name;
%if contains(filename, '.emujoy') %takes only emujoy files from folder
%extracts raw data from logfile
Logs = importdata([DataFolderPath,'\',filename]);
if class(Logs) == 'double'
Log_Data = Logs;
else
Log_Data = Logs.data;
end
Time_Vec = Log_Data(:,1);%Time (in computer clock)
X_Vec = Log_Data(:,2);%Valence
Y_Vec = Log_Data(:,3);%Arousal
Trigger_Vec = Log_Data(:,4);%Triggers
Would I need to remove the headerlines before or after importing the data?
Thanks in advance!

댓글 수: 3

Sindar
Sindar 2020년 10월 5일
what tool are you using to import data? Most have a 'headerlines' option
Sindar
Sindar 2020년 10월 5일
importdata has headerline options

댓글을 달려면 로그인하십시오.

답변 (1개)

Ayush Gupta
Ayush Gupta 2020년 10월 8일

0 개 추천

The data from the text file can be imported using importdata function in MATLAB. To ignore the header of the file we can use the headerlinesIn option which defines after how many lines it will read the data. To refer to the documentation of importdata and see some examples to understand its working, refer here.

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2020년 10월 5일

댓글:

2020년 10월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by