Skip to content
Merged
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
7 changes: 6 additions & 1 deletion bin/generate-csvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,9 +1304,14 @@ def write_csvs(self):
if updated_count > 0:
logger.info(f"Populated {updated_count} missing geography codes from boundary data")

# Create local-plan-boundary column (semicolon-separated version of local-planning-authorities)
for plan in local_plans_sorted:
lpa_codes = plan.get('local-planning-authorities', '')
plan['local-plan-boundary'] = lpa_codes.replace('-', ';') if lpa_codes else ''

self._write_csv('local-plan.csv', local_plans_sorted, [
'reference', 'name', 'dataset', 'period-start-date', 'period-end-date',
'organisations', 'local-planning-authorities', 'mineral-planning-authorities',
'organisations', 'local-plan-boundary', 'local-planning-authorities', 'mineral-planning-authorities',
'waste-planning-authorities', 'local-plan-process', 'required-housing',
'documentation-url', 'document-url', 'entry-date', 'start-date', 'end-date', 'notes'
])
Expand Down
13 changes: 10 additions & 3 deletions bin/generate-timetable-data/generate_mineral_waste_timetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,8 +1663,14 @@ def extract_adoption_for_plan(row):
# Sort by curie-organisations and local-plan (adoption-date)
plans = plans.sort_values(['curie-organisations', 'local-plan']).reset_index(drop=True)

# Create authorities column with semicolons instead of dashes if requested
authorities_column_name = 'mineral-planning-authorities' if 'mineral' in geography_column_name.lower() else 'waste-planning-authorities'
plans[authorities_column_name] = plans['geography-codes'].apply(
lambda x: x.replace('-', ';') if pd.notna(x) else x
)

# Select and reorder columns (local-plan first after curie-organisations)
plans = plans[['local-plan', 'name', 'curie-organisations', 'geography-codes', 'start-year', 'end-year', 'adoption-date', 'end-date', 'documentation-url', 'document-url']]
plans = plans[['local-plan', 'name', 'curie-organisations', 'geography-codes', authorities_column_name, 'start-year', 'end-year', 'adoption-date', 'end-date', 'documentation-url', 'document-url']]

# Rename local-plan to reference for plans CSVs
rename_dict = {'local-plan': 'reference',
Expand All @@ -1673,6 +1679,7 @@ def extract_adoption_for_plan(row):
'curie-organisations': 'organisations',
'adoption-date': 'start-date',
'geography-codes': geography_column_name}
# Don't rename the authorities column - keep it as-is
plans = plans.rename(columns=rename_dict)

# Add entry-date
Expand All @@ -1683,11 +1690,11 @@ def extract_adoption_for_plan(row):
return len(plans)

# Create mineral plans (type='M' or 'M;W')
mineral_count = create_plans_csv(melted_df, ['M', 'M;W'], 'dataset/mineral-plan.csv', 'mineral-planning-authority')
mineral_count = create_plans_csv(melted_df, ['M', 'M;W'], 'dataset/mineral-plan.csv', 'mineral-planning-boundary')
print(f"✓ Exported {mineral_count} mineral plans to dataset/mineral-plan.csv")

# Create waste plans (type='W' or 'M;W')
waste_count = create_plans_csv(melted_df, ['W', 'M;W'], 'dataset/waste-plan.csv', 'waste-planning-authority')
waste_count = create_plans_csv(melted_df, ['W', 'M;W'], 'dataset/waste-plan.csv', 'waste-planning-boundary')
print(f"✓ Exported {waste_count} waste plans to dataset/waste-plan.csv")

# Create mineral-plan-timetable.csv and waste-plan-timetable.csv
Expand Down
Loading