How to import data and remove headers
145 views (last 30 days)
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
Date: Wed Jan 09 13:12:16 GMT 2019
*** Music Start ***1547039542802;-0.890625;0.2199004975124379;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;
Log_Data = Logs.data;
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!
Ayush Gupta on 8 Oct 2020
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.