The following curl code works:
curl --form [email protected] --form benchmark=Public_AR_Census2010 http://geocoding.geo.census.gov/geocoder/locations/addressbatch
t.csv is simply
1, 800 Wilshire Blvd, Los Angeles, CA, 90017
How do I mimic this in python. So far all of my attempts have resulted in 'Bad Requests'. I am also trying to keep everything in memory--no writing to file.
One attempt:
import requests
url = "http://geocoding.geo.census.gov/geocoder/json/addressbatch"
# data is csv like string with , and \n
ddata = urllib.urlencode({'addressFile' : data, 'benchmark' : 'Public_AR_Current'})
r = requests.get(url + "?" + ddata) # Forcibly closed by remote
requests.put("http://geocoding.geo.census.gov/geocoder/json/addressbatch", ddata)