Okay, so the Address
field was quite painful to parse. However I did manage to parse the data based on my particular requirements.
- The
Address
always has a<br>
between the Street & City.
So I did the following:
var splitBasedOnHTML = Regex.Split(column[2], @"\br<br>");
The column[]
contains my address in index two
. So after that call, it will automatically position my Unit and Street in Index Zero
. The City, State, and Zip will be located Index One
.
So I did another split, to break the City, State, and Zip like this:
var splitBasedOnSpace = splitBasedOnHtml[1].Split(' ');
After that I now end up with the following:
6313 SW 203rd Ave // splitBasedOnHtml[0]
Portland, // splitBasedonSpace[0]
OR // splitBasedOnSpace[1]
97224 // splitBasedOnSpace[2]
So I simply mapped my properties to those individual array index's.
This solution makes the assumption that the Unit is apart of the Street, which become an okay sacrifice as the data is being imported into another web-site and can be modified by particular people later on.
That is how I solved the parse issues, this solution may not be viable for others in this boat but hopefully this is a nice alternative or points in a good direction. What the method looks like:
public static Map AddressMapper(IList<string> column)
{
var map = new Map();
var splitBasedOnHTML = Regex.Split(column[2], @"\b<br>");
var splitBasedOnSpace = splitBasedOnHTML[1].Split(' ');
map.Street = splitBasedOnHTML[0];
map.City = splitBasedOnSpace[0].Replace(@",", " ");
map.State = splitBasedOnSpace[1];
map.Zip = spliteBasedOnSpace[2];
return map;
}