Reading a txt file and arranging a table

Hi!
I have a txt file in which there are X,Y,Z positions of a tracking.
The file doesn't go to cape, so it's all in a single line:
I tried to use this code
filename=('G-B.txt');
T = readtable(filename,'Delimiter','"');
But i obtain only a long string of "VariableNames":
How can i het the value in the correct way?
I would need a nx3 matrix, with each line fullfilled with 3 values (lat,long,ele)

6 comentarios

Did you happen to leave out a few characters from the beginning of the display of the file? I would expect it to start with
<trkpt
before what you posted.
If it does start with that, then use regexp() with named tokens and the 'names' option.
I notice in what you post that what is probably elevation information is in the form
<ele>"NUMBER"<ele>
I wonder why it is not instead
<ele>"NUMBER"</ele>
If it were /ele after instead of <ele> then I would have suggested trying to use the xml parser.
Are you sure you do not need the time information as well?
andrea vironda
andrea vironda el 27 de Jul. de 2020
Also the time would be important.
  • xml parser?
It would be great, but i don't think it would be able to manage this kind of file. This is the original:
In the post above i posted a modified version of it
Mohammad Sami
Mohammad Sami el 27 de Jul. de 2020
You can either use regexp to capture the pattern or you can use the parseXML function to directly convert the xml file.
andrea vironda
andrea vironda el 27 de Jul. de 2020
Editada: andrea vironda el 27 de Jul. de 2020
I succeeded to read the xml but the data I need are nestled on several levels.
for example the first elevation i can get is here:
mlStruct.Children(4).Children(4).Children(1).Children(1).Data
How to deal with this kind of data?
-----*
Here the latitude and longitude are under "Attributes", But elevation in under "Children"
Image Analyst
Image Analyst el 27 de Jul. de 2020
You forgot to attach your file. Please attach your XML text file. Zip it up if you have to. Then use the paper clip icon.
Here's the code and the starting .xml
clc; clear all; close all
filename=('camping-du-domaine-de-griggione-bastia.xml');
mlStruct = parseXML(filename)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Variables en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 27 de Jul. de 2020

Comentada:

el 27 de Jul. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by