I'm having trouble extracting some data properly and into a SQL db, which i'm hoping someone can help with. The data is scraped from a website and represents Dutch postal codes and cities
The official Dutch postal codes are composed of 4 digits, a space in between, and a 2 capital letter addition. For example
1234 AA
or
5523 ZB
The website combines that with the name of the city in one HTML string. In other words this is what it looks like ideally:
1234 AA Amsterdam
The first problem that pops up is that the websites allows users to ignore the addition when plugging in a postal code
1234 Amsterdam
And the second problem is that some of the cities have names that do not begin with a standard Capital letter:
5555 AD 's-Hertogenbosch
or
2244 's-Gravenzande
I'm essentially trying to split everything, regardless of what special conditions pop up
What i would like to get in the end is each entry separated into 3 parts The postal 4 digit code, the postal addition (if any), and the name of the city (including the weird symbols)
For example: Column 1:
5555
Column 2:
AD or null
Column 3:
's-Hertogenbosch
I'm fairly new to Regex, so the only thing i could come up with was
r"^([^(a-z)]*).*"g
which admittedly is terrible.
Any help on the answer or resources that might help me get to one would be greatly appreciated!