Thought I might share this piece of code I've written to aid me in data extraction in a professional environment.
The purpose of the code is to be able to determine which Country a UK postcode is listed in (to assist in a marketing campaign).
Find the source here: https://github.com/IndigoFuzz/PureBasic ... stcode.pbi
An example of use:
Code: Select all
IncludeFile "include/postcode.pbi"
; Create List of Test Postcodes
NewList ToCheck.s()
AddElement(ToCheck()) : ToCheck() = "CF5 1AB"
AddElement(ToCheck()) : ToCheck() = "NP2 1AB"
AddElement(ToCheck()) : ToCheck() = "ST20 1AB"
AddElement(ToCheck()) : ToCheck() = "BT1 1AB"
AddElement(ToCheck()) : ToCheck() = "DT4 1AB"
; Initialise Postcode Query Module
PostCode::Initialise()
; Query Postcodes
ForEach ToCheck()
Debug "Checking Postcode: " + ToCheck()
Debug " - Country: " + PostCode::CountryStr(PostCode::GetCountry(ToCheck()))
Debug " - Region: " + PostCode::GetRegion(ToCheck())
Debug " - Town: " + PostCode::GetTown(ToCheck())
Debug ""
Next
; - Uninitialise Postcode Module
PostCode::Release()
