Skip to content

Commit 5efe571

Browse files
committed
Document script helpers
1 parent f98ce01 commit 5efe571

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/data/scripts/find_cha_buildings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
found = []
44

5+
# Reads from cha_building_names, which is sourced from:
6+
# https://www.thecha.org/residents/public-housing/find-public-housing
7+
#
8+
# This script will then log the correctly formatted data, and you can copy that into
9+
# buildings-custom-info.constant
510
with open("src/data/scripts/cha_building_names.txt") as f:
611
looking_for = f.read().splitlines()
712
with open("src/data/source/ChicagoEnergyBenchmarking.csv") as a:
@@ -15,4 +20,4 @@
1520

1621
for place in found:
1722
print('// '+place[1])
18-
print("'" + place[0] + "'" + ": { owner: BuildingOwners.cha.key },")
23+
print("'" + place[0] + "'" + ": { owner: BuildingOwners.cha.key },")

src/data/scripts/find_city_buildings.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,41 @@
22

33
found = []
44

5+
# Read through an export of the City of Chicago Land Inventory, filtering to only buildings with
6+
# the status 'Owned by City' and Managing Organization = 'AIS'
7+
#
8+
# Source: https://data.cityofchicago.org/Community-Economic-Development/City-Owned-Land-Inventory/aksk-kvfp
9+
#
10+
# This script will then log the correctly formatted data, and you can copy that into
11+
# buildings-custom-info.constant
512
def find_addresses():
613
with open('src/data/source/City-Owned_Land_Inventory.csv') as source_file:
714
city_file = csv.DictReader(source_file)
815
MAIN_FILE_ADDRESS_INDEX = 4
916
MAIN_FILE_ID_INDEX = 1
10-
17+
1118
with open('src/data/source/ChicagoEnergyBenchmarking.csv', newline='') as all_data:
1219
whole_file = all_data.read().splitlines()
1320
for i, line in enumerate(city_file):
1421
if line["Address"].strip() == "" or line["Property Status"] != "Owned by City":
1522
continue
23+
1624
for j, whole_file_line in enumerate(whole_file):
1725
print(i, j)
1826
address = whole_file_line.split(",")[MAIN_FILE_ADDRESS_INDEX]
27+
28+
# Only include buildings that are owned AND managed by the city. Some buildings
29+
# are on land that appears to be owned by the city from their inventory
1930
if line["Address"].lower().strip().replace(" ", "") == address.lower().strip().replace(" ", "") and line["Managing Organization"] == "AIS":
2031
found.append(whole_file_line.split(",")[MAIN_FILE_ID_INDEX])
2132
break
22-
33+
2334
if i%50 == 49:
2435
with open("temp.txt", "w") as f:
2536
f.write(str(len(found)))
2637
f.write("/n")
2738
f.write(", ".join(found))
28-
39+
2940
print("found addresses: ", found.__str__(), len(found))
3041

3142
def print_tags():
@@ -39,4 +50,4 @@ def print_tags():
3950
found.remove(line["ID"])
4051

4152
find_addresses()
42-
print_tags()
53+
print_tags()

src/data/scripts/find_cps_schools.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
cps_schools:[str, str] = {}
44

5+
# Find CPS (Chicago Public Schools) properties by searching specifically for the term CPS in the
6+
# property name.
7+
#
8+
# NOTE: This does not include ALL buildings, so we manually tagged selective enrollment schools
9+
#
10+
# This script will then log the correctly formatted data, and you can copy that into
11+
# buildings-custom-info.constant
512
with open('src/data/source/ChicagoEnergyBenchmarking.csv', newline='') as csvfile:
613
whole_file = csv.DictReader(csvfile)
14+
715
for row in whole_file:
816
if "CPS" in row["Property Name"]:
917
cps_schools[row["ID"]] = row["Property Name"]
1018

1119
for id, school in cps_schools.items():
12-
cleaned_school_name = school.removesuffix("-CPS").strip()
13-
print("// "+cleaned_school_name)
14-
print('"' + id + '"' + ": { owner: BuildingOwners.cps.key },")
20+
cleaned_school_name = school.removesuffix("-CPS").strip()
21+
22+
print("// " + cleaned_school_name)
23+
print('"' + id + '"' + ": { owner: BuildingOwners.cps.key },")

0 commit comments

Comments
 (0)