Scanning a text file for bits and pieces of information
Mostra commenti meno recenti
Hi.
I'm new to matlab and I'm a bit stuck in where to begin with coding a program to open a text file, read specific strings and extract information from specific strings. Here's my general outline and an example of the text format I'm trying to read.
Example format:(wanted information has asterisks on either side of it)
<solution solution_id="telemetry" name="SITE_FRAME" add_date="2004-01-26T12:04:23Z" index1="1">
<reference_frame name="SITE_FRAME" index1=" *0* "/>
<offset x=" *-0.0* " y=" *0.0* " z=" *0.0* "/>
<orientation s="1.0" v1="0.0" v2="0.0" v3="0.0"/>
</solution>
<alias>
<old index1="0" index2="0" index3="1" index4="59"/>
<new index1="1"/>
</alias>
<solution solution_id="telemetry" name="SITE_FRAME" add_date="2004-01-26T12:04:25Z" index1="2">
<reference_frame name="SITE_FRAME" index1=" *1* "/>
<offset x=" *-0.0* " y=" *0.0* " z=" *0.0* "/>
<orientation s="1.0" v1="0.0" v2="0.0" v3="0.0"/>
</solution>
<alias>
<old index1="1" index2="0" index3="0" index4="13"/>
<new index1="2"/>
Outline:
Open file 'mer_site' (that's the file that contains this format of information)
Look for instances of * information
ie the parts that say 'name=SITE_FRAME" index1="*"/>'
export the * information into a vector (total size [1x158])
Look for instances of * information
ie the parts that say '<offset x="*" y="*" z="*"/>'
export the * information into a vector (total size [3x158])
Close File
So far, all I know is that I need
fid=fopen('mer_site')
something with textscan
something about putting the results from textscan into a cell
closing the file
I'm not sure which arguments I need for textscan because the information is mixed.
I'd be super grateful if anyone could help with this!!!
9 Commenti
Walter Roberson
il 20 Lug 2015
Would you be able to use an xml parser on this?
Elena H.
il 20 Lug 2015
per isakson
il 20 Lug 2015
Modificato: per isakson
il 20 Lug 2015
You show an excerpt of a file and we guess that it is an xml-file. We are probably mistaken.
Elena H.
il 20 Lug 2015
Walter Roberson
il 20 Lug 2015
That file does not appear to be in Simple File Verification (SFV) format. Perhaps it has something to do with State Fusion Vector ?
Elena H.
il 20 Lug 2015
per isakson
il 20 Lug 2015
I found an "issue" with mer1_master.
<solution solution_id="telemetry" name="SITE_FRAME" add_date="2013-12-03T17:01:12Z" index1="182">
<reference_frame name="SITE_FRAME" index1="181"/>
....
<solution add_date="2014-02-16T19:02:11Z" index1="183" name="SITE_FRAME" solution_id="telemetry">
<reference_frame index1="182" name="SITE_FRAME"/>
....
The order of the "items" changes after index, 183. I guess that is not significant with an xml-file.
Walter Roberson
il 20 Lug 2015
The directory above says that the files are indeed XML files.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Environment and Settings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!