[H-GEN] Edit massive XML files

Mick bareman at tpg.com.au
Tue Sep 20 03:42:46 EDT 2011


On Mon, 19 Sep 2011 16:34:08 +1200
Johannes Sprigode <johannes at paradise.net.nz> wrote:

> [ Humbug *General* list - semi-serious discussions about Humbug
> and     ] [ Unix-related topics. Posts from non-subscribed addresses
> will vanish. ]
> 
> Mick,
> 
> awk is your friend.
> 
> A very basic awk script below
> 
> ---> cut below <---
> #!/bin/sh
> 
> BEGIN {
> 	s1 = "<tag k=\"source\"";
> 	s2 = "<tag k=\"postal_code\"";
> }
> 
> {
> 	if ((index($0, s1) != 0) || (index($0, s2) != 0));else print
> $0; } 
> ---> cut above <---
> 
> call with awk -f mick.awk mick.xml
> 
> where mick.awk is above script and mick.xml is your input file.
> 
> Cheers
> 
> Johannes
> 
Many thanks to all who offered advice, Johannes' offering provided what
I was looking for, it removed what I wanted and only what I wanted.

Unfortunately, I was trying to take an unsuitable shortcut to filter
the data and was minimally successful in advancing towards my final
goal of eliminating irrelevant data and rectifying inconsistent tagging
of nodes.

I guess my only option is to learn python & ruby in order to tweak
QGIS' Open Street Map importer to meet my needs.

mick



More information about the General mailing list