Switch Latitude And Longitude With Regular Expression
It happens that you receive a file with longitude and latitude just in the opposite order that you would like to have. It’s fairly easy to switch those without loading it into Excel or Calc and doing Ctrl + C
and Ctrl + V
on columns.
If you have a file with tabular data that looks like this:
50.52, 60.15
70.96, 80.1
-55.23, 62.03
You can use Sublime Text to switch the values:
- Press
Ctrl + H
- Copy
(\-?\d+\.?\d+),?[\t ]*(\-?\d+\.?\d+)$
to Find What input - Copy
$2,$1
to Replace With input
Hit Replace All button and you’re done.