Generate a schema.org compliant JSON file of Registered Community Amateur Sports Clubs in the UK.
This JSON is based on the 13 October 2023 file.
HMRC publish a list of all registered CASCs in the UK. This is an ODS file that is updated infrequently. This project aims to convert that file into a JSON file that is schema.org compliant.
ABBOTS LANGLEY BOWLING CLUB ,12 GREENWAYS,ABBOTS LANGLEY,,,WD5 0EU
{
"@context": "https://schema.org",
"@type": "SportsOrganization",
"name": "ABBOTS LANGLEY BOWLING CLUB",
"address": {
"@type": "PostalAddress",
"streetAddress": "12 Greenways",
"addressLocality": "Abbots Langley",
"addressRegion": "Hertfordshire",
"postalCode": "WD5 0EU",
"addressCountry": {
"@type": "Country",
"name": "GB"
}
}
}
The ODS file is converted to a CSV file using LibreOffice. The CSV file is then converted to a JSON file using a TypeScript script.
- If the
Postcode
column has content, use that to populate theaddressCountry
andpostalCode
fields. - If there's no
addressRegion
then theaddressLocality
is used to look up the county in thecounties.json
file. - If
addressRegion
is still empty, then a lookup is made tohttps://api.postcodes.io/postcodes/
to populate it from anadmin_county
response. - The column immediately before
addressRegion
is used foraddressLocality
. - All address fields are title cased.
bun convert.ts