<commit_before>import csv

import geocoder

import haversine

def nearest_distance(origin):
  g = geocoder.google(origin)
  input = g.latlng
  lat1 = float(input[0])
  lon1 = float(input[1])

  min_distance = float("inf")
  counter = 0
  smallest_index = 0

  with open("store-locations.csv", "rU") as infile:

    reader = csv.DictReader(infile, delimiter=",")
    converted_reader = list(reader)

    for row in converted_reader:
      lat2 = float(row["Latitude"])
      lon2 = float(row["Longitude"])
      distance = (haversine.distance((lat1, lon1), (lat2, lon2)))

      if distance < min_distance:
        min_distance = distance
        smallest_index = counter
      counter += 1

    address = converted_reader[smallest_index]["Address"]
    city = converted_reader[smallest_index]["City"]
    state = converted_reader[smallest_index]["State"]
    zip_code = converted_reader[smallest_index]["Zip Code"]

    return "%(address)s, %(city)s, %(state)s %(zip_code)s" % locals()

<commit_msg>no need to cast to list, using enumerate<commit_after>import csv

import geocoder

import haversine

def nearest_distance(origin):
  g = geocoder.google(origin)
  input = g.latlng
  lat1 = float(input[0])
  lon1 = float(input[1])

  min_distance = float("inf")
  smallest_index = 0

  with open("store-locations.csv", "rU") as infile:

    reader = csv.DictReader(infile, delimiter=",")

    for counter, row in enumerate(reader):
      lat2 = float(row["Latitude"])
      lon2 = float(row["Longitude"])
      distance = (haversine.distance((lat1, lon1), (lat2, lon2)))

      if distance < min_distance:
        min_distance = distance
        smallest_index = counter

    address = reader[smallest_index]["Address"]
    city = reader[smallest_index]["City"]
    state = reader[smallest_index]["State"]
    zip_code = reader[smallest_index]["Zip Code"]

    ## WHOA! A read-world usage of locals()!!! How on earth did you end up using that?!?! Super cool, although at the same time totally insane ;)
    return "%(address)s, %(city)s, %(state)s %(zip_code)s" % locals()


{'fraction_non_alphanumeric': 0.13416988416988418, 'fraction_numerical': 0.011583011583011582, 'mean_word_length': 3.9239904988123517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '3551077', 'n_tokens_mistral': 704, 'n_tokens_neox': 677, 'n_words': 164}