Skip to content

Commit

Permalink
Import script for Ribble Valley (2024-05-02) (closes #6576)
Browse files Browse the repository at this point in the history
  • Loading branch information
polling-bot-4000 authored and awdem committed Mar 14, 2024
1 parent b847e10 commit 45e81a5
Showing 1 changed file with 24 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,49 +1,29 @@
from data_importers.base_importers import BaseStationsDistrictsImporter
from django.contrib.gis.geos import Point
from data_importers.management.commands import BaseXpressDemocracyClubCsvImporter


class Command(BaseStationsDistrictsImporter):
srid = 27700
class Command(BaseXpressDemocracyClubCsvImporter):
council_id = "RIB"
elections = ["2023-05-04"]
districts_name = "2023-05-04/2023-03-29T13:51:45/PD.geojson"
stations_name = "2023-05-04/2023-03-29T13:51:45/PS.geojson"
stations_filetype = "geojson"
districts_filetype = "geojson"
addresses_name = (
"2024-05-02/2024-03-13T10:03:27.884984/Democracy_Club__02May2024.tsv"
)
stations_name = (
"2024-05-02/2024-03-13T10:03:27.884984/Democracy_Club__02May2024.tsv"
)
elections = ["2024-05-02"]
csv_delimiter = "\t"

def station_record_to_dict(self, record):
stations = []
codes = (
c.strip()
for c in (
record["properties"]["CODE"],
record["properties"]["CODE 2"],
record["properties"]["CODE 3"],
)
if c
)
name = record["properties"]["Name"].strip()
address = record["properties"]["Address"].strip()
postcode = record["properties"]["Postcode"].strip()
location = Point(
record["properties"]["longitude"],
record["properties"]["latitude"],
srid=4326,
)
for code in codes:
stations.append(
{
"internal_council_id": code,
"address": f"{name}\n{address}",
"postcode": postcode,
"polling_district_id": code,
"location": location,
}
)
return stations
def address_record_to_dict(self, record):
uprn = record.property_urn.strip().lstrip("0")

def district_record_to_dict(self, record):
return {
"internal_council_id": record["properties"]["CODE"].strip(),
"name": record["properties"]["NAME"],
}
if uprn in [
"10093891716", # 44 HACKINGS CARAVAN PARK ELKER LANE, BILLINGTON
"10093893136", # BROCKTHRON LAITHE, WIGGLESWORTH ROAD, TOSSIDE, SKIPTON
]:
return None
if record.addressline6 in [
# split
"BB7 9GL",
]:
return None

return super().address_record_to_dict(record)

0 comments on commit 45e81a5

Please sign in to comment.