Skip to content

Commit

Permalink
scripts to find buildings for large owners
Browse files Browse the repository at this point in the history
  • Loading branch information
SuragNuthulapaty committed Jan 12, 2024
1 parent a105610 commit 1142d16
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/data/scripts/find_cha_buildings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import csv

found = []

with open("src/data/scripts/cha_building_names.txt") as f:
looking_for = f.read().splitlines()
with open("src/data/source/ChicagoEnergyBenchmarking.csv") as a:
whole_file = list(csv.DictReader(a))

for i, p in enumerate(looking_for):
for j, whole_file_line in enumerate(whole_file):
if p.lower().strip().replace(" ", "") in whole_file_line["Property Name"].lower().strip().replace(" ", ""):
found.append((whole_file_line["ID"], whole_file_line["Property Name"]))
break

for place in found:
print('// '+place[1])
print("'" + place[0] + "'" + ": { owner: BuildingOwners.cha.key },")
43 changes: 43 additions & 0 deletions src/data/scripts/find_city_buildings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import csv

found = []

def find_addresses():
with open('src/data/source/City-Owned_Land_Inventory.csv') as source_file:
city_file = csv.DictReader(source_file)
MAIN_FILE_ADDRESS_INDEX = 4
MAIN_FILE_ID_INDEX = 1

with open('src/data/source/ChicagoEnergyBenchmarking.csv', newline='') as all_data:
whole_file = all_data.read().splitlines()
for i, line in enumerate(city_file):
if line["Address"].strip() == "" or line["Property Status"] != "Owned by City":
continue
for j, whole_file_line in enumerate(whole_file):
print(i, j)
address = whole_file_line.split(",")[MAIN_FILE_ADDRESS_INDEX]
if line["Address"].lower().strip().replace(" ", "") == address.lower().strip().replace(" ", ""):
found.append(whole_file_line.split(",")[MAIN_FILE_ID_INDEX])
break

if i%50 == 49:
print(found)
with open("temp.txt", "w") as f:
f.write(str(len(found)))
f.write("/n")
f.write(", ".join(found))

print("found addresses: ", found.__str__(), len(found))

def print_tags():
with open('src/data/source/ChicagoEnergyBenchmarking.csv', newline='') as all_data:
whole_dict = csv.DictReader(all_data)

for line in whole_dict:
if line["ID"] in found:
print("// "+line["Property Name"])
print(line["ID"] + ": { owner: BuildingOwners.cityofchicago.key },")
found.remove(line["ID"])

find_addresses()
print_tags()
14 changes: 14 additions & 0 deletions src/data/scripts/find_cps_schools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import csv

cps_schools:[str, str] = {}

with open('src/data/source/ChicagoEnergyBenchmarking.csv', newline='') as csvfile:
whole_file = csv.DictReader(csvfile)
for row in whole_file:
if "CPS" in row["Property Name"]:
cps_schools[row["ID"]] = row["Property Name"]

for id, school in cps_schools.items():
cleaned_school_name = school.removesuffix("-CPS").strip()
print("// "+cleaned_school_name)
print('"' + id + '"' + ": { owner: BuildingOwners.cps.key },")

0 comments on commit 1142d16

Please sign in to comment.