Geocode a CSV in the browser, no terminal
The person with the spreadsheet should not need a terminal. The local server has a page for exactly that: drop a CSV, pick the address column, download the result.
New Geocode addresses Browser Server, Docker Websites, help desks
What you have
A CSV with an address column, and someone who can start the server once:
store,address Loop,"233 S Wacker Dr, Chicago, IL 60606" Magnificent Mile,"600 N Michigan Ave, Chicago, IL 60611" Wrigleyville,"1060 W Addison St, Chicago, IL 60613"
Steps
1. Start the server for the country of the addresses:
$ gridpin serve usa.bin --port 8080
2. Open http://127.0.0.1:8080/ui. The page is served by the same program:
$ curl -s http://127.0.0.1:8080/ui | grep -o '<h1>[^<]*</h1>' <h1>Geocode a CSV</h1>
3. Drop the CSV, check the address column (a column named address, query or q is picked for you), press Geocode, then Download CSV. The page sends the rows to the server 500 at a time, the same request as this one:
$ curl -s -X POST http://127.0.0.1:8080/v1/geocode -H "Content-Type: application/json" -d '{"queries": ["233 S Wacker Dr, Chicago, IL 60606"], "k": 1}'
{"results":[[{"commune":"Chicago","confidence":0.949999988079071,"flags":["street_exact","commune_exact","house_rep","pc_exact"],"housenumber":"233","lat":41.878658,"lon":-87.6358684,"match_level":"PointAddress","match_status":"M","postcode":"60606","precision":"house","score":7.2687788009643555,"street":"South WACKER Drive","weak":false}]]}
What you get
The file back with gp_lat, gp_lon, gp_match_level and the address found; the page shows the count of each match level and the first 20 rows, each with a link to see the point on a map. With the three stores above it shows PointAddress: 3.
Why it works
The page is one HTML file inside the program: no outside script, font or service. It reads the CSV in the browser and sends only the address column to /v1/geocode of the server it came from.
Limits
- The map link opens openstreetmap.org with that point: the only outside request, and only when clicked.
- The whole file is read into the browser's memory: a very large file is a job for the command line.
- To serve colleagues, start it with
--host 0.0.0.0on a trusted network; it has no login.
All its keys: command reference. The function: a page to geocode a CSV.