Scanning a text file for bits and pieces of information
古いコメントを表示
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 件のコメント
Walter Roberson
2015 年 7 月 20 日
Would you be able to use an xml parser on this?
Elena H.
2015 年 7 月 20 日
per isakson
2015 年 7 月 20 日
編集済み: per isakson
2015 年 7 月 20 日
You show an excerpt of a file and we guess that it is an xml-file. We are probably mistaken.
Elena H.
2015 年 7 月 20 日
Walter Roberson
2015 年 7 月 20 日
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.
2015 年 7 月 20 日
per isakson
2015 年 7 月 20 日
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
2015 年 7 月 20 日
The directory above says that the files are indeed XML files.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!