4 deleted 4 characters in body
source | link

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

test2[[2out[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

test2[[2out[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[test2[[2Length[out[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

Please provide a mathematica9 answer as I only have this version. But I might buy v10 soon so I'm also interested in the new v10 features :)

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

test2[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

test2[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[test2[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

Please provide a mathematica9 answer as I only have this version. But I might buy v10 soon so I'm also interested in the new v10 features :)

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

out[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

out[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[out[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

Please provide a mathematica9 answer as I only have this version. But I might buy v10 soon so I'm also interested in the new v10 features :)

3 added 126 characters in body
source | link

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

test2[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

test2[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[test2[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

Please provide a mathematica9 answer as I only have this version. But I might buy v10 soon so I'm also interested in the new v10 features :)

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

test2[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

test2[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[test2[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

I'm have some trouble formatting the Output of a 'Import' request. I get this as a return of a google places API request:

out={"html_attributions" -> {}, 
    "results" -> {{"geometry" -> {"location" -> {"lat" -> 48.35593, 
    "lng" -> 10.89459}}, 
    "id" -> "4f8d22dd53bf7c6eb79360a324ce616999b82b5f", 
    "place_id" -> "ChIJA7PvOkG9nkcRmJkimVDMQQ4", 
    "reference" -> 
    "CmRcAAAAdwzUsk-\
     DX8sUI1HMyFVujZ2gu8claGrxhJ8ZVj80rBBEkbiiLtQnqCalgnOvIMkHF17f5TzkB6hXc\
     STLG36HPB_KU08JczxpHSIpc1Z4UlKqhTHXTShYTKimqxowUsUBEhBRY_fMjrk_\
     UIiaZ9U1MMPsGhQPwm98QfAw74FogeUryqxPxGMv8g"}, {"geometry" -> \
     {"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}}, 
     "id" -> "6d4568d42a2011543410ab2d0d805b521562a237", 
     "place_id" -> "ChIJBzM8CmgenEcRqrj1bDQ6WDY", 
     "reference" -> 
     "CmRZAAAAqcP7N7Cv35I_HLTMKiuYajWRh6qFNadB_\
      trryO8EgtOYhyz2Wjfq7sYaKAwXKU_5HLq4tB1tS5_f4QZNDeM_\
      lUEd8XI74DNz5CntTTbGIdOPs0hYsb6MOvitVUBT1PaoEhCo3qnHXZYwLyX8vhRapm9LGh\
      QzEWMmVxnp1wpetlGDMlp_OC55QQ"}}, "status" -> "OK"}

by trial and error I found a way to get the location of the first place:

test2[[2, 2]][[1, 1]][[2, 1]]

"location" -> {"lat" -> 48.35593, "lng" -> 10.895}

the second place is

test2[[2, 2]][[2, 1]][[2, 1]]

"location" -> {"lat" -> 48.3747, "lng" -> 10.8957}

the number of places is

Length[test2[[2, 2]]]

2

For longer outputs I'd like to get all locations automatically. My naive approach was

[[2, 2]][[#, 1]][[2, 1]]&/@out

but that does not work.

How can I get a structured output of all the location data from this JSON output?

I'm also looking for general advice how to best handle google places and JSON output.

Perhaps someone even knows a nice way to autmatically display the geodata on a map in mathematica.

Please provide a mathematica9 answer as I only have this version. But I might buy v10 soon so I'm also interested in the new v10 features :)

2 edited tags
| link
1
source | link