Skip to content

Instantly share code, notes, and snippets.

View thilohuellmann's full-sized avatar
👀
curious

Thilo Huellmann thilohuellmann

👀
curious
View GitHub Profile
import requests
import json
import csv
from tqdm import *
import requests
import json
import csv
from tqdm import *
import requests
import json
import csv
from tqdm import *
def addresses_from_csv(path=None, column=None):
addresses = []
with open(path, 'r') as f:
reader = csv.reader(f)
for row in reader:
addresses.append(row[column])
return addresses
# Get addresses from CSV
addresses = addresses_from_csv(path='path/to/your/file.csv', column=0)
# Set Google Maps API key
api_key = YOUR_API_KEY
# Initialize array for transformed addresses
transformed = []
transformed.append(['Country', 'Post code', 'City', 'Street & No'])
@thilohuellmann
thilohuellmann / main.py
Last active May 17, 2019 12:40
medium4
for query in tqdm(addresses):
# API call, storing information as JSON
url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + query + '&lang=en&key=' + api_key
r = requests.get(url)
data = r.json()
# clear all values to avoid appending values from previous iterations a second time
number = street = country = postal_code = city = ''
{
"results" : [
{
"address_components" : [
{
"long_name" : "221B",
"short_name" : "221B",
"types" : [ "street_number" ]
},
{
for query in tqdm(addresses):
# API call, storing information as JSON
url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + query + '&lang=en&key=' + api_key
r = requests.get(url)
data = r.json()
with open('transformed_addresses.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
for row in transformed:
writer.writerow(row)

100 Days Of ML Code - Example Log

Use this as a base template. Create your own repository on GitHub and start logging your work daily!

Day 0: February 29, 2016 (Example 1)

(delete me or comment me out)

Today's Progress: Fixed CSS, worked on canvas functionality for the app.

Thoughts: I really struggled with CSS, but, overall, I feel like I am slowly getting better at it. Canvas is still new for me, but I managed to figure out some basic functionality.