How to properly extract data from text file?

I have a data in a text file that looks basically like this:

LineType: 1
PlayMode: Single
GameType: OneBalloon
LineType: SumR3
TranslationSpeed: 0
SensivityBalloon1: 0.09
SensivityBalloon2: 0
LevelLength: 20
Season: Summer
Backgrounddifficulty: Easy
StarScore[1] DistanceScore[1] StabilityScore[1] ScoreFrames[1] Frame[1] Time[1] ForcePlayer1[1] BalloonPath_X[1] BalloonPath_Y[1] CharacterPath_X[1] CharacterPath_Y[1] IsInactive[1]
0 0 0 0 0 0 30653 0 4.225888 0 2.150741 0
1 0 0 0 1 0 30641 0 -2.579402 0 -4.643577 0

And I am using this to extract data starting from the StarScore:

file = fullfile('file.txt');
Subject(1).T = readtable(file,'Delimiter',' ', ...
'ReadVariableNames',true, 'HeaderLines', 10);
Subject(1).T(:, 13) = [];

Two questions I have:

1) The problem with this is that, the headerline should be at 11, but MATLAB extracted the first data as the header if I put HeaderLines to 11. It skips the first line. Why?

2) How to extract the first few information from the text file on a different cell and stop before it reaches starScore?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

The first one is (relatively) easy — you set ‘ReadVariableNames’,true whose meaning per documentation is “the first row of the region to read contains the variable names for the table.” Hence, the count of lines to skip is based on all the information to be parsed, not just the data portion; if you want the header line for names it becomes one of the data lines. So in that case ‘HeaderLines’ is just 10; you want the 11 th line.

I don’t understand the second request, sorry…

ADDENDUM

OK, the second came to me Another approach to same end result…

hdrdata=regexp(textread(file,'%s','headerlines', 10, ...
'delimiter','\n','whitespace',''),'split');

which will leave you a 10x1 cell array each of which contains the text/value pair.

While TMW has deprecated the venerable textread over its uptown

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How is the pandemic affecting interest to purchase essential personal care products in key markets?

FRED API and Python

Metadata Management, A Critical Element in Data Governance

How I Became a Recruiter-Magnet on LinkedIn

Types Of Transformation For Better Normal Distribution .

Traffic lights that illuminate the poles to help drivers see better …..

Bringing Data Analytics Mindset to Nonprofits

Time-Series Forecasting: How to predict future data using ARMA , ARIMA and SARIMA model.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

Using World Bank Data on Pandas for Beginners

Countries’ credit rating dataset, pt. 1: wrangling & cleaning

How to convince yourself and others that your model is good?

Data Types in Python