Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:20:44+00:00 2026-06-04T21:20:44+00:00

import csv from geopy import geocoders import time g = geocoders.GeocoderDotUS() spamReader = csv.reader(open(‘locations.csv’,

  • 0
import csv
from geopy import geocoders
import time

g = geocoders.GeocoderDotUS()

spamReader = csv.reader(open('locations.csv', 'rb'), delimiter='\t', quotechar='|')

f = open("output.txt",'w')

for row in spamReader:
    a = ', '.join(row)
    #exactly_one = False
    time.sleep(1)


    place, (lat, lng) = g.geocode(a)


    if None in (lat, lng):
        f.write("none")
    else:
        b = str(place) + "," + "[" + str(lat) + "," + str(lng) + "]" + "\n"
        print b
        f.write(b)

So I have established that if GeocoderDotUS does not find an address it will return None. I have written some script to attempt to check for None however I still seem to be getting this trace back. I am a bit perplexed.

Traceback (most recent call last):
File "C:\Users\Penguin\workspace\geocode-nojansdatabase\src\GeocoderDotUS.py", line 17, in <module>
place, (lat, lng) = g.geocode(a)
TypeError: 'NoneType' object is not iterable

Is there some error in my check for None systax? Thanks in advance for any help out….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:20:46+00:00Added an answer on June 4, 2026 at 9:20 pm

    I don’t know anything about geopy, but it looks like the problem is just what you said: if geocode doesn’t find it, it returns None. Just None, not a tuple with None as the elements. So you need to check for None before you assign the results to lat and lng. Something like:

    geoResult = g.geocode(a)
    if geoResult is None:
        f.write("none")
    
    # If we get here, the result is not None and we can proceed normally
    place, (lat, lng) = geoResult
    b = "..." # continue with your processing here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import csv from geopy import geocoders import time g = geocoders.GeocoderDotUS() spamReader = csv.reader(open('locations.csv',
import csv from geopy import geocoders g = geocoders.Google() spamReader = csv.reader(open('locations.csv', 'rb'), delimiter='\t',
I'm trying to import a csv (that is a data extract from a SQL
I'm trying to import a matrix (about 80.000 rows) from a csv file to
I took this script from here : import csv from itertools import izip f
I have a class for products import from CSV file operation which requires about
I'm refactoring existing class to support Products import from CSV file.   Requirements: 1)
I am trying to import a CSV from a url using the feeds module,
I'm writing an import from CSV and have been able to successfully manually set
We have written a number of SSIS packages that import data from CSV files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.