Skip to content

Commit

Permalink
Document script helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
vkoves committed Jan 17, 2024
1 parent f98ce01 commit 5efe571
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/data/scripts/find_cha_buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

found = []

# Reads from cha_building_names, which is sourced from:
# https://www.thecha.org/residents/public-housing/find-public-housing
#
# This script will then log the correctly formatted data, and you can copy that into
# buildings-custom-info.constant
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:
Expand All @@ -15,4 +20,4 @@

for place in found:
print('// '+place[1])
print("'" + place[0] + "'" + ": { owner: BuildingOwners.cha.key },")
print("'" + place[0] + "'" + ": { owner: BuildingOwners.cha.key },")
19 changes: 15 additions & 4 deletions src/data/scripts/find_city_buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,41 @@

found = []

# Read through an export of the City of Chicago Land Inventory, filtering to only buildings with
# the status 'Owned by City' and Managing Organization = 'AIS'
#
# Source: https://data.cityofchicago.org/Community-Economic-Development/City-Owned-Land-Inventory/aksk-kvfp
#
# This script will then log the correctly formatted data, and you can copy that into
# buildings-custom-info.constant
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]

# Only include buildings that are owned AND managed by the city. Some buildings
# are on land that appears to be owned by the city from their inventory
if line["Address"].lower().strip().replace(" ", "") == address.lower().strip().replace(" ", "") and line["Managing Organization"] == "AIS":
found.append(whole_file_line.split(",")[MAIN_FILE_ID_INDEX])
break

if i%50 == 49:
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():
Expand All @@ -39,4 +50,4 @@ def print_tags():
found.remove(line["ID"])

find_addresses()
print_tags()
print_tags()
15 changes: 12 additions & 3 deletions src/data/scripts/find_cps_schools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

cps_schools:[str, str] = {}

# Find CPS (Chicago Public Schools) properties by searching specifically for the term CPS in the
# property name.
#
# NOTE: This does not include ALL buildings, so we manually tagged selective enrollment schools
#
# This script will then log the correctly formatted data, and you can copy that into
# buildings-custom-info.constant
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 },")
cleaned_school_name = school.removesuffix("-CPS").strip()

print("// " + cleaned_school_name)
print('"' + id + '"' + ": { owner: BuildingOwners.cps.key },")

0 comments on commit 5efe571

Please sign in to comment.