<jupyter_start><jupyter_text>Import Libraries<jupyter_code>import googlemaps
import pandas as pd
import time
import os<jupyter_output><empty_output><jupyter_text>Read Config File<jupyter_code>import configparser
config = configparser.ConfigParser()
config.read('config.ini')
input_file = config['DEFAULT']['Input-File']
output_file = config['DEFAULT']['Output-File']
threshold = config['DEFAULT']['Threshold']
api_key = config['DEFAULT']['Google-API-Key']
address_column = config['DEFAULT']['Address-Column']<jupyter_output><empty_output><jupyter_text>Read CSV/Excel File<jupyter_code>if os.path.splitext(input_file)[1] == ".csv":
    df = pd.read_csv(input_file, header = None, encoding="UTF-8")
else:
    df = pd.read_excel(input_file, header = None, encoding="UTF-8")
print(len(df))<jupyter_output>62<jupyter_text>Check Threshold (Default Value : 1000)<jupyter_code>if int(threshold) > 1000:
    df = df.iloc[1000:int(threshold),]
else:
    df = df.iloc[0:1000,]<jupyter_output><empty_output><jupyter_text>Get Address Value<jupyter_code>if address_column.isdigit():
    address_list = df[int(address_column)].tolist()
else:
    address_list = df[address_column].tolist()<jupyter_output><empty_output><jupyter_text>Add New Columns (Latitude, Longtitude)<jupyter_code>new_column_list = ["latitude","longtitude"]
for i in new_column_list:
    df[i] = None<jupyter_output><empty_output><jupyter_text>Connect Google Geocoding API<jupyter_code>gmaps = googlemaps.Client(key=api_key)<jupyter_output><empty_output><jupyter_text>Append Value into New Columns<jupyter_code>start = time.time()

for index,row in df.iterrows():
    address = df.loc[index,0]
    try:
        geocode_result = gmaps.geocode(address)
        lat = geocode_result[0]["geometry"]["location"]["lat"]
        long = geocode_result[0]["geometry"]["location"]["lng"]
        coordinate = [lat,long]
        df.loc[[index],new_column_list] = coordinate
    except:
        print("error address: " + address)
        
end = time.time()
print(end-start)<jupyter_output>29.38843274116516<jupyter_text>Write into CSV<jupyter_code>df.rename(columns={0: "address"}, inplace=True)
df.to_csv(output_file,index=0,encoding='UTF-8')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14756317689530685, 'fraction_numerical': 0.019855595667870037, 'mean_word_length': 7.150735294117647, 'pattern_counts': {'":': 1, '<': 35, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '480191', 'license': 'Unlicense', 'n_tokens_mistral': 823, 'n_tokens_neox': 799, 'n_words': 111, 'path': 'f0023/f0023.ipynb', 'repo_name': 'soda-lab/Features', 'size': '2216'}