Separate Address number and name

Denis McMahon denismfmcmahon at gmail.com
Thu Jan 23 13:11:30 EST 2014


On Wed, 22 Jan 2014 17:35:22 +0000, Denis McMahon wrote:

> On Tue, 21 Jan 2014 16:06:56 -0800, Shane Konings wrote:

>> The following is a sample of the data.

> A mechanism using regexes

Just to follow up, using regexes I transformed the sample data that I 
believe is as follows:

inputData = [
"1	1067 Niagara Stone Rd, W, Niagara-On-The-Lake, ON L0S 1J0",
"2	4260 Mountainview Rd, Lincoln, ON L0R 1B2",
"3	25 Hunter Rd, Grimsby, E, ON L3M 4A3",
"4	1091 Hutchinson Rd, Haldimand, ON N0A 1K0",
"5	5172 Green Lane Rd, Lincoln, ON L0R 1B3",
"6	500 Glenridge Ave, East, St. Catharines, ON L2S 3A1",
"7	471 Foss Rd, Pelham, ON L0S 1C0",
"8	758 Niagara Stone Rd, Niagara-On-The-Lake, ON L0S 1J0",
"9	3836 Main St, North, Lincoln, ON L0R 1S0",
"10	1025 York Rd, W, Niagara-On-The-Lake, ON L0S 1P0"
]

Into the following:

1,1067,Niagara Stone,Rd,W,Niagara-On-The-Lake,ON,L0S 1J0
2,4260,Mountainview,Rd,,Lincoln,ON,L0R 1B2
3,25,Hunter,Rd,Grimsby,E,ON,L3M 4A3
4,1091,Hutchinson,Rd,,Haldimand,ON,N0A 1K0
5,5172,Green Lane,Rd,,Lincoln,ON,L0R 1B3
6,500,Glenridge,Ave,East,St. Catharines,ON,L2S 3A1
7,471,Foss,Rd,,Pelham,ON,L0S 1C0
8,758,Niagara Stone,Rd,,Niagara-On-The-Lake,ON,L0S 1J0
9,3836,Main,St,North,Lincoln,ON,L0R 1S0
10,1025,York,Rd,W,Niagara-On-The-Lake,ON,L0S 1P0

Which should then read into Excel as CSV just fine.

One final question though, why are you using excel to manipulate data 
that looks as if it would be better held in and manipulated by a database?

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list