I have a text file that contains data in the following format. This is a sample of the data it contains. The file is correct and in the correct format:
<node id="1647008557" lat="36.6536840" lon="-121.7938995" version="1" timestam p="2012-02-25T14:03:54Z" changeset="10787766" uid="294728" user="skew-t">
<tag k="highway" v="turning_circle"/>
</node>
<way id="10459706" version="2" timestamp="2010-03-27T18:21:32Z" changeset="4247030" uid="20587" user="balrog-kun">
<nd ref="89705976"/>
<nd ref="89798118"/>
<nd ref="89798120"/>
<nd ref="89798122"/>
<nd ref="89798124"/>
<nd ref="89798126"/>
<nd ref="89798128"/>
<nd ref="89798130"/>
<tag k="highway" v="residential"/>
<tag k="name" v="Engineer Road"/>
<tag k="tiger:cfcc" v="A41"/>
<tag k="tiger:county" v="Livingston, CA"/>
<tag k="tiger:name_base" v="Engineer"/>
<tag k="tiger:name_type" v="Rd"/>
<tag k="tiger:reviewed" v="no"/>
<tag k="tiger:separated" v="no"/>
<tag k="tiger:source" v="tiger_import_dch_v0.6_20070809"/>
<tag k="tiger:tlid" v="196844016"/>
</way>
<way id="10461171" version="3" timestamp="2014-01-07T00:17:59Z" changeset="19855176" uid="1871178" user="RBoggs">
<nd ref="89804458"/>
<nd ref="89804460"/>
<nd ref="89804463"/>
<nd ref="89804464"/>
<nd ref="89804466"/>
<nd ref="89804468"/>
<tag k="access" v="no"/>
<tag k="highway" v="residential"/>
<tag k="motor_vehicle" v="no"/>
<tag k="name" v="5th Cutoff Street"/>
<tag k="tiger:cfcc" v="A41"/>
<tag k="tiger:county" v="Marysville, CA"/>
<tag k="tiger:name_base" v="5th Cutoff"/>
<tag k="tiger:name_type" v="St"/>
<tag k="tiger:reviewed" v="no"/>
</way>
<way id="151860745" version="1" timestamp="2012-02-25T14:03:59Z" changeset="10787766" uid="294728" user="skew-t">
<nd ref="1647008614"/>
<nd ref="1647008545"/>
<nd ref="1647008605"/>
<nd ref="1647008555"/>
<nd ref="1647008557"/>
<tag k="highway" v="service"/>
</way>
And I am trying to print out the name
within the way id
section along with the way id
itself, the sequence number the nd ref
is at, and the nd ref
id.
Like so in the correct output:
$ awk -f table.awk file.txt | head
road,way_id,seq_num,node_ref_id
Engineer Road,10459706,1,89705976
Engineer Road,10459706,2,89798118
Engineer Road,10459706,3,89798120
Engineer Road,10459706,4,89798122
Engineer Road,10459706,5,89798124
Engineer Road,10459706,6,89798126
Engineer Road,10459706,7,89798128
Engineer Road,10459706,8,89798130
5th Cutoff Street,10461171,1,89804458
5th Cutoff Street,10461171,2,89804460
5th Cutoff Street,10461171,3,89804463
5th Cutoff Street,10461171,4,89804464
5th Cutoff Street,10461171,5,89804466
5th Cutoff Street,10461171,6,89804468
How would I print that output by ignoring the lines that do not contain <tag k="name"
within the <way>
tag?