GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Bulk Querying by reading values from CSV file  XML
Forum Index -> General
Author Message
balajihpe



Joined: 28/04/2016 14:29:21
Messages: 1
Offline

Hi,

Is there any way to get bulk data by passing a country name or a city name so that by hitting the api I can get the JSON response for all the latitudes and longitudes which matches the specified country/city.
wmo



Joined: 12/10/2016 18:15:16
Messages: 1
Offline

Here's a solution for ".. reading values from csv file", using grep and the very handy jq utility:

Code:
 grep -i feira cities1000.txt  | jq --slurp --raw-input --raw-output   'split("\n") | map(split("\t")) |  map({"geonameid": .[0],
            "name": .[1],
            "asciiname": .[2],
            "latitude": .[4],
            "longitude": .[5],
            "country": .[8],
            "population": .[14],
            "elevation": .[16] } )'
 


Result:

Code:
 [
   {
     "geonameid": "3399679",
     "name": "Feira Nova",
     "asciiname": "Feira Nova",
     "latitude": "-7.95083",
     "longitude": "-35.38917",
     "country": "BR",
     "population": "12984",
     "elevation": "163"
   },
   {
     "geonameid": "3463478",
     "name": "Feira de Santana",
     "asciiname": "Feira de Santana",
     "latitude": "-12.26667",
     "longitude": "-38.96667",
     "country": "BR",
     "population": "481911",
     "elevation": "223"
   },
 


Ciao,

Willem
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team