Formatting .dat gps file

2 views (last 30 days)
Eric Hills
Eric Hills on 18 Oct 2020
Answered: Eric Sofen on 13 Nov 2020
I have no idea how to format this .dat gps file from raw gps data into a table with Latitude, longitude, timestamp, and altitude. I will be using this data to create vs time graphs so I think the easiest way to have the data formatted is in arrays for each variable. it was in .dat so i couldn't attach it so here is what part of it it looks like as text.
^-^
lat: -31.114#
^-^
long: 150.850#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920425.000#
^-^
lat: -31.114#
^-^
long: 150.877#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598920456.000#
^-^
lat: -31.114#
^-^
long: 150.903#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920489.000#
^-^
lat: -31.114#
^-^
long: 150.931#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920521.000#
^-^
lat: -31.114#
^-^
long: 150.957#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920549.000#
^-^
lat: -31.115#
^-^
long: 150.981#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920585.000#
^-^
lat: -31.116#
^-^
long: 151.010#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920616.000#
^-^
lat: -31.116#
^-^
long: 151.036#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920647.000#
^-^
lat: -31.116#
^-^
long: 151.061#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920665.000#
^-^
lat: -31.118#
^-^
long: 151.076#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920675.000#
^-^
lat: -31.118#
^-^
long: 151.084#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598920681.000#
^-^
lat: -31.116#
^-^
long: 151.088#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920687.000#
^-^
lat: -31.111#
^-^
long: 151.089#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920694.000#
^-^
lat: -31.107#
^-^
long: 151.088#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920700.000#
^-^
lat: -31.106#
^-^
long: 151.085#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920707.000#
^-^
lat: -31.105#
^-^
long: 151.081#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920713.000#
^-^
lat: -31.105#
^-^
long: 151.077#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920722.000#
^-^
lat: -31.105#
^-^
long: 151.072#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920728.000#
^-^
lat: -31.105#
^-^
long: 151.069#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920762.000#
^-^
lat: -31.104#
^-^
long: 151.049#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920793.000#
^-^
lat: -31.104#
^-^
long: 151.031#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920823.000#
^-^
lat: -31.104#
^-^
long: 151.014#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920858.000#
^-^
lat: -31.104#
^-^
long: 150.993#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920888.000#
^-^
lat: -31.103#
^-^
long: 150.974#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598920922.000#
^-^
lat: -31.103#
^-^
long: 150.954#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920952.000#
^-^
lat: -31.103#
^-^
long: 150.936#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598920984.000#
^-^
lat: -31.103#
^-^
long: 150.917#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921014.000#
^-^
lat: -31.103#
^-^
long: 150.898#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921047.000#
^-^
lat: -31.103#
^-^
long: 150.879#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921080.000#
^-^
lat: -31.102#
^-^
long: 150.858#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921112.000#
^-^
lat: -31.101#
^-^
long: 150.839#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921143.000#
^-^
lat: -31.101#
^-^
long: 150.820#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921164.000#
^-^
lat: -31.101#
^-^
long: 150.807#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921170.000#
^-^
lat: -31.101#
^-^
long: 150.803#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921176.000#
^-^
lat: -31.102#
^-^
long: 150.800#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921182.000#
^-^
lat: -31.103#
^-^
long: 150.796#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921207.000#
^-^
lat: -31.093#
^-^
long: 150.791#
^-^
Altitude: 13575.000#
^-^
Timestamp: 1598921213.000#
^-^
lat: -31.091#
^-^
long: 150.796#
^-^
Altitude: 13600.000#
^-^
Timestamp: 1598921219.000#
^-^
lat: -31.090#
^-^
long: 150.800#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921226.000#
^-^
lat: -31.089#
^-^
long: 150.805#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921235.000#
^-^
lat: -31.089#
^-^
long: 150.812#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598921241.000#
^-^
lat: -31.089#
^-^
long: 150.818#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921275.000#
^-^
lat: -31.089#
^-^
long: 150.845#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921309.000#
^-^
lat: -31.089#
^-^
long: 150.873#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921339.000#
^-^
lat: -31.090#
^-^
long: 150.898#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921371.000#
^-^
lat: -31.091#
^-^
long: 150.924#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921404.000#
^-^
lat: -31.091#
^-^
long: 150.952#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921435.000#
^-^
lat: -31.091#
^-^
long: 150.977#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921467.000#
^-^
lat: -31.092#
^-^
long: 151.005#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921499.000#
^-^
lat: -31.092#
^-^
long: 151.030#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921530.000#
^-^
lat: -31.092#
^-^
long: 151.057#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921546.000#
^-^
lat: -31.093#
^-^
long: 151.070#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921553.000#
^-^
lat: -31.094#
^-^
long: 151.075#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921562.000#
^-^
lat: -31.096#
^-^
long: 151.082#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921571.000#
^-^
lat: -31.096#
^-^
long: 151.089#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921577.000#
^-^
lat: -31.093#
^-^
long: 151.094#
^-^
Altitude: 13625.000#
^-^
Timestamp: 1598921584.000#
^-^
lat: -31.089#
^-^
long: 151.096#
^-^
Altitude: 13600.000#
^-^
Timestamp: 1598921590.000#
^-^
lat: -31.085#
^-^
long: 151.095#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921596.000#
^-^
lat: -31.083#
^-^
long: 151.092#
^-^
Altitude: 13575.000#
^-^
Timestamp: 1598921602.000#
^-^
lat: -31.083#
^-^
long: 151.088#
^-^
Altitude: 13575.000#
^-^
Timestamp: 1598921609.000#
^-^
lat: -31.082#
^-^
long: 151.085#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921615.000#
^-^
lat: -31.082#
^-^
long: 151.081#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921621.000#
^-^
lat: -31.082#
^-^
long: 151.077#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921627.000#
^-^
lat: -31.082#
^-^
long: 151.074#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921657.000#
^-^
lat: -31.081#
^-^
long: 151.055#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921690.000#
^-^
lat: -31.081#
^-^
long: 151.036#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921724.000#
^-^
lat: -31.081#
^-^
long: 151.016#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921757.000#
^-^
lat: -31.081#
^-^
long: 150.996#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921787.000#
^-^
lat: -31.081#
^-^
long: 150.978#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921819.000#
^-^
lat: -31.080#
^-^
long: 150.958#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921849.000#
^-^
lat: -31.080#
^-^
long: 150.939#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921881.000#
^-^
lat: -31.080#
^-^
long: 150.920#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921913.000#
^-^
lat: -31.079#
^-^
long: 150.901#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598921943.000#
^-^
lat: -31.079#
^-^
long: 150.882#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598921976.000#
^-^
lat: -31.079#
^-^
long: 150.862#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922007.000#
^-^
lat: -31.078#
^-^
long: 150.843#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922039.000#
^-^
lat: -31.078#
^-^
long: 150.824#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922067.000#
^-^
lat: -31.078#
^-^
long: 150.807#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922074.000#
^-^
lat: -31.079#
^-^
long: 150.803#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922081.000#
^-^
lat: -31.080#
^-^
long: 150.800#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922087.000#
^-^
lat: -31.081#
^-^
long: 150.796#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922112.000#
^-^
lat: -31.071#
^-^
long: 150.787#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922119.000#
^-^
lat: -31.067#
^-^
long: 150.790#
^-^
Altitude: 13575.000#
^-^
Timestamp: 1598922125.000#
^-^
lat: -31.065#
^-^
long: 150.794#
^-^
Altitude: 13600.000#
^-^
Timestamp: 1598922150.000#
^-^
lat: -31.066#
^-^
long: 150.814#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922184.000#
^-^
lat: -31.067#
^-^
long: 150.841#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922215.000#
^-^
lat: -31.068#
^-^
long: 150.866#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922246.000#
^-^
lat: -31.068#
^-^
long: 150.892#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922277.000#
^-^
lat: -31.068#
^-^
long: 150.917#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922308.000#
^-^
lat: -31.068#
^-^
long: 150.943#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922340.000#
^-^
lat: -31.069#
^-^
long: 150.970#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922372.000#
^-^
lat: -31.069#
^-^
long: 150.996#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922404.000#
^-^
lat: -31.069#
^-^
long: 151.023#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922435.000#
^-^
lat: -31.070#
^-^
long: 151.048#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922466.000#
^-^
lat: -31.070#
^-^
long: 151.073#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922499.000#
^-^
lat: -31.070#
^-^
long: 151.101#
^-^
Altitude: 13550.000#
^-^
Timestamp: 1598922508.000#
^-^
lat: -31.072#
^-^
long: 151.108#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598922514.000#
^-^
lat: -31.072#
^-^
long: 151.113#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922520.000#
^-^
lat: -31.069#
^-^
long: 151.117#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922526.000#
^-^
lat: -31.065#
^-^
long: 151.118#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598922532.000#
^-^
lat: -31.062#
^-^
long: 151.116#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922538.000#
^-^
lat: -31.060#
^-^
long: 151.113#
^-^
Altitude: 13525.000#
^-^
Timestamp: 1598922544.000#
^-^
lat: -31.060#
^-^
long: 151.110#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598922551.000#
^-^
lat: -31.060#
^-^
long: 151.106#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598922559.000#
^-^
lat: -31.059#
^-^
long: 151.101#
^-^
Altitude: 13500.000#
^-^
Timestamp: 1598922565.000#
^-^
lat: -31.059#
^-^
long: 151.097#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598922602.000#
^-^
lat: -31.059#
^-^
long: 151.075#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598922633.000#
^-^
lat: -31.059#
^-^
long: 151.056#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598922666.000#
^-^
lat: -31.058#
^-^
long: 151.036#
^-^
Altitude: 13475.000#
^-^
Timestamp: 1598922697.000#

Answers (2)

Chaitanya Mallela
Chaitanya Mallela on 21 Oct 2020
To read this dat file as a table, the variables have to be aligned as column vectors. Try modifying the dat file as four column vectors i.e., Latitude, Longitude, Timestamp, and Altitude.

Eric Sofen
Eric Sofen on 13 Nov 2020
Unless there's an existing reader for that file format, you're going to need to read it in as text and parse it into something more structured. You could use readlines to read it into a string array and go from there. Something like this:
s = readlines('gps.dat');
s(contains(s,"^-^")) = [];
s = strip(s); % get rid of leading whitespace
s = erase(s,"#");
s = split(s,': ');
lab = s(:,1);
d = double(s(:,2));
t = table(d(lab == 'lat'), d(lab == 'long'), d(lab == 'Altitude'), d(lab == 'Timestamp'));
t.Properties.VariableNames = ["lat","long","Altitude","Timestamp"];
The resulting table looks like this
>> head(t)
ans =
8×4 table
lat long Altitude Timestamp
_______ ______ ________ __________
-31.114 150.85 13500 1.5989e+09
-31.114 150.88 13475 1.5989e+09
-31.114 150.9 13500 1.5989e+09
-31.114 150.93 13500 1.5989e+09
-31.114 150.96 13500 1.5989e+09
-31.115 150.98 13500 1.5989e+09
-31.116 151.01 13500 1.5989e+09
-31.116 151.04 13500 1.5989e+09

Products

Community Treasure Hunt

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

Start Hunting!