title: Geocoding using Geopy and Python
body: <p>I am trying to Geocode a CSV file that contains the name of the location and a parsed out address which includes Address number, Street name, city, zip, country. I want to use GEOPY and ArcGIS Geocodes through Geopy.I wanted to create a code that loops through my csv of 5000+ entries and gives me the latitude and longitude in separate columns in my CSV. I want to use ArcGIS Geocoding service through Geopy. Can anyone provide me with a code to get started? Thanks! </p>
  
  <p>Here is my script:</p>
  
  <pre><code>import csv
  from geopy.geocoders import ArcGIS
  
  
  geolocator = ArcGIS()     # here some parameters are needed
  
  with open('C:/Users/v-albaut/Desktop/Test_Geo.csv', 'rb') as csvinput:
      with open('output.csv', 'w') as csvoutput:
          output_fieldnames = ['Name','Address', 'Latitude', 'Longitude']
          writer = csv.DictWriter(csvoutput, delimiter=',', fieldnames=output_fieldnames)
          reader = csv.DictReader(csvinput)
  
          for row in reader:
              # here you have to replace the dict item by your csv column names
              query = ','.join(str(x) for x in (row['Name'], row['Address']))
              Address, (latitude, longitude) = geolocator.geocode(query)
  
              # here is the writing section
              output_row = {}
              output_row['Name'] = Name
              output_row['Address'] = Address
              output_row['Latitude'] = Latitude
              output_row['Longitude'] =Longitude
              writer.writerow(output_row)
  </code></pre>