I am parsing a JSON document in Python and I have gotten nearly the whole process to work except I am having trouble converting a GPS string into the correct form.
I have the following form:
"gsx$gps":{"$t":"44°21′N 68°13′W\ufeff / \ufeff44.35°N 68.21°W\ufeff / 44.35; -68.21\ufeff (Acadia)"}
and that is from this HTML form:
44°21′N 68°13′W / 44.35°N 68.21°W / 44.35; -68.21 (Acadia)
and I want the final product to be a string that looks like this:
(44.35, -68.21)
here are a few other example JSON strings just to give you some more to work with:
"gsx$gps":{"$t":"14°15′S 170°41′W\ufeff / \ufeff14.25°S 170.68°W\ufeff / -14.25; -170.68\ufeff (American Samoa)"}
"gsx$gps":{"$t":"38°41′N 109°34′W\ufeff / \ufeff38.68°N 109.57°W\ufeff / 38.68; -109.57\ufeff (Arches)"}
I have the following:
GPSlocation = entry['gsx$gps']['$t']
and then I don't know how to get GPSlocation into the form that I want above.
not super elegant but it works...also you are not parsing json ... just parsing a string...
import re
center_part = GPSLocation.split("/")[1]
N,W = centerpart.split()
N,W = N.split("\xb0")[0],W.split("\xb0")[0]
tpl = (N,W)
print tpl
on a side note these are not ints ...