[H-GEN] Edit massive XML files

Peter Robinson pjr at itee.uq.edu.au
Tue Sep 20 17:42:20 EDT 2011


On 09/20/2011 05:42 PM, Mick wrote:
> [ Humbug *General* list - semi-serious discussions about Humbug and     ]
> [ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
>
> 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

My view is that if you take the time to learn how to use XML parsing in 
some language (e.g. Python) then
other possibilities of data processing/transformation might open up :)


Peter





More information about the General mailing list