Re: Reverse multiple gps coordinates using AppleScript?

41 views
Skip to first unread message

Christopher Stone

unread,
Apr 26, 2013, 2:36:22 PM4/26/13
to textwr...@googlegroups.com
On Apr 26, 2013, at 13:02, Gregor Knell <grego...@gmail.com> wrote:
> There are over 15,000 lines that look similar to these:
> <coordinates>34.14135381,-118.23758366</coordinates>
> ...
______________________________________________________________________

Hey Gregor,

You can use Applescript for such a task, but since this is basically a straightforward find/replace you could also use a regex in the find dialog — or for something more reusable a text filter.

-------------------------------------------------------------------------------------------

#! /usr/bin/env perl
use v5.12; use strict; use warnings;
#----------------------------------------

while (<>) {
if ( m{([[:blank:]]*<coordinates>)(\d+\.\d+)(,)(-?\d+\.\d+)(</coordinates>)}i) {
say "$1$4$3$2$5";
} else {
print;
}
}

-------------------------------------------------------------------------------------------

Save the above as a file in:

~/Library/Application Support/TextWrangler/Text Filters/

Run it from the menu: {Text} --> {Apply Text Filter} or assign it a keyboard shortcut.

Be sure and test on a COPY of your data.

--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages