Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing units column in all datasets #405

Draft
wants to merge 1 commit into
base: dluhc-integration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64,966 changes: 32,483 additions & 32,483 deletions dataUpload/Index-of-Multiple-Deprivation-2007-Rank.csv

Large diffs are not rendered by default.

64,966 changes: 32,483 additions & 32,483 deletions dataUpload/Index-of-Multiple-Deprivation-2007-Score.csv

Large diffs are not rendered by default.

64,966 changes: 32,483 additions & 32,483 deletions dataUpload/Index-of-Multiple-Deprivation-2010-Rank.csv

Large diffs are not rendered by default.

64,966 changes: 32,483 additions & 32,483 deletions dataUpload/Index-of-Multiple-Deprivation-2010-Score.csv

Large diffs are not rendered by default.

14,976 changes: 7,488 additions & 7,488 deletions dataUpload/Permanent-dwellings-completed-England-District-By-Tenure-filtered-2022.csv

Large diffs are not rendered by default.

249,352 changes: 124,676 additions & 124,676 deletions dataUpload/Permanent-dwellings-completed-England-District-By-Tenure-filtered.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FeatureCode,DateCode,Measurement,Units,Value,DCLG Planning Decisions Major and Minor Developmets by Development Type
E06000021,Year ending 2021-03-31,Decisions,,5,Gypsy and traveller pitches
E06000021,Year ending 2020-06-30,Decisions,,9,Offices research and development / light industry
E06000021,Year ending 2017-06-30,Decisions,,8,General industry storage warehousing
E06000021,Year ending 2020-12-31,Decisions,,7,Other Major and Minor Developments
E06000021,Year ending 2016-06-30,Decisions,,10,Gypsy and traveller pitches
FeatureCode,DateCode,Measurement,Units,Value,DCLG Planning Decisions Major and Minor Developmets by Development Type
E06000021,Year ending 2021-03-31,Decisions,application-decisions,5,Gypsy and traveller pitches
E06000021,Year ending 2020-06-30,Decisions,application-decisions,9,Offices research and development / light industry
E06000021,Year ending 2017-06-30,Decisions,application-decisions,8,General industry storage warehousing
E06000021,Year ending 2020-12-31,Decisions,application-decisions,7,Other Major and Minor Developments
E06000021,Year ending 2016-06-30,Decisions,application-decisions,10,Gypsy and traveller pitches
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FeatureCode,DateCode,Measurement,Units,Value,DCLG Planning Decisions Major and Minor Developmets by Development Type
E06000021,Year ending 2019-03-31,Decisions,,17,Retail distribution servicing
E06000021,Year ending 2018-03-31,Decisions,,4,Offices research and development / light industry
E06000021,Year ending 2019-12-31,Decisions,,15,Offices research and development / light industry
E06000021,Year ending 2014-09-30,Decisions,,0,Gypsy and traveller pitches
E06000021,Year ending 2016-12-31,Decisions,,101,Other Major and Minor Developments
E06000021,Year ending 2014-09-30,Decisions,,67,Retail distribution servicing
E06000021,Year ending 2017-06-30,Decisions,,118,Dwellings
FeatureCode,DateCode,Measurement,Units,Value,DCLG Planning Decisions Major and Minor Developmets by Development Type
E06000021,Year ending 2019-03-31,Decisions,application-decisions,17,Retail distribution servicing
E06000021,Year ending 2018-03-31,Decisions,application-decisions,4,Offices research and development / light industry
E06000021,Year ending 2019-12-31,Decisions,application-decisions,15,Offices research and development / light industry
E06000021,Year ending 2014-09-30,Decisions,application-decisions,0,Gypsy and traveller pitches
E06000021,Year ending 2016-12-31,Decisions,application-decisions,101,Other Major and Minor Developments
E06000021,Year ending 2014-09-30,Decisions,application-decisions,67,Retail distribution servicing
E06000021,Year ending 2017-06-30,Decisions,application-decisions,118,Dwellings
145,814 changes: 72,907 additions & 72,907 deletions ...-Decisions-Major-and-Minor-Developments-England-District-by-Development-Type-filtered.csv

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions dataUpload/add-units.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import csv
import sys

# Define a dictionary to map measurement values to their corresponding units
measurement_units = {
"IMD rank": "ordinal-position",
"IMD score": "deprivation-score",
"Rank": "ordinal-position",
"Score": "deprivation-score",
"Decile": "decile-group",
"Decisions": "application-decisions",
"Completions": "building-completions"
}

# Function to update the units column based on the measurement value
def update_units(row):
measurement = row['Measurement']
if measurement in measurement_units:
row['Units'] = measurement_units[measurement]
return row

if len(sys.argv) != 2:
print("Usage: python script.py input_file")
sys.exit(1)

# Input file path
input_file = sys.argv[1]

# Create a temporary file to store the updated data
temp_file = input_file + '.tmp'

# Read the CSV file and update the units column
with open(input_file, 'r') as csvfile:
reader = csv.DictReader(csvfile)
fieldnames = reader.fieldnames # Retrieve the original column titles
rows = [update_units(row) for row in reader]

# Write the updated rows to the temporary file
with open(temp_file, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(rows)

# Replace the input file with the temporary file
os.replace(temp_file, input_file)

print("Units updated successfully!")
8 changes: 4 additions & 4 deletions dataUpload/upload-indicies-of-deprivation.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# run locally with docker compose:
# hurl upload-indicies-of-deprivation.hurl --variable series=English-Indices-of-Deprivation --variable datahost-base-url=http://localhost:8889 --variable admin_password=password

#DELETE {{datahost-base-url}}/data/{{series}}
#[BasicAuth]
#idp: {{admin_password}}
DELETE {{datahost-base-url}}/data/{{series}}
[BasicAuth]
idp: {{admin_password}}

#HTTP 204
HTTP 204


PUT {{datahost-base-url}}/data/{{series}}
Expand Down
8 changes: 4 additions & 4 deletions dataUpload/upload-permanent-dwellings.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# run locally with docker compose:
# hurl upload-permanent-dwellings.hurl --variable series=Permanent-dwellings-completed --variable datahost-base-url=http://localhost:8889 --variable admin_password=password

# DELETE {{datahost-base-url}}/data/{{series}}
# [BasicAuth]
# idp: {{admin_password}}
DELETE {{datahost-base-url}}/data/{{series}}
[BasicAuth]
idp: {{admin_password}}

# HTTP 204
HTTP 204


PUT {{datahost-base-url}}/data/{{series}}
Expand Down