Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 4 cannot produce "linkedin_connections.json" #35

Open
maggiex opened this issue Aug 26, 2019 · 0 comments
Open

Chapter 4 cannot produce "linkedin_connections.json" #35

maggiex opened this issue Aug 26, 2019 · 0 comments

Comments

@maggiex
Copy link

maggiex commented Aug 26, 2019

After successfully geocoding locations of linkedin connections, one cannot save the connections data into json. The reported error after running the cell is the following:

#Save the processed data
CONNECTIONS_DATA = 'linkedin_connections.json'

# Loop over contacts and update the location information to store the
# string address, also adding latitude and longitude information
def serialize_contacts(contacts, output_filename):
    for c in contacts:
        location = c['Location']
        if location != None:
            # Convert the location to a string for serialization
            c.update([('Location', location.address)])
            c.update([('Lat', location.latitude)])
            c.update([('Lon', location.longitude)])
    f = open(output_filename, 'w')
    f.write(json.dumps(contacts, indent=1))
    f.close()
    return
serialize_contacts(contacts, CONNECTIONS_DATA)

AttributeError Traceback (most recent call last)
in
16 f.close()
17 return
---> 18 serialize_contacts(contacts, CONNECTIONS_DATA)

in serialize_contacts(contacts, output_filename)
9 if location != None:
10 # Convert the location to a string for serialization
---> 11 c.update([('Location', location.address)])
12 c.update([('Lat', location.latitude)])
13 c.update([('Lon', location.longitude)])

AttributeError: 'str' object has no attribute 'address'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant