Separate Address number and name
John Gordon
gordon at panix.com
Tue Jan 21 21:46:15 EST 2014
In <9fe1b47b-65ce-4063-9188-07b81cdba49f at googlegroups.com> Shane Konings <shane.konings at gmail.com> writes:
> I have the following sample from a data set and I am looking to split the address number and name into separate headings as seen below.
> FarmID Address
> 1 1067 Niagara Stone
> 2 4260 Mountainview
> 3 25 Hunter
> 4 1091 Hutchinson
> 5 5172 Green Lane
> 6 500 Glenridge
> 7 471 Foss
> 8 758 Niagara Stone
> 9 3836 Main
> 10 1025 York
> FarmID AddressNum AddressName
> 1 1067 Niagara Stone
> 2 4260 Mountainview
> 3 25 Hunter
> 4 1091 Hutchinson
> 5 5172 Green Lane
> 6 500 Glenridge
> 7 471 Foss
> 8 758 Niagara Stone
> 9 3836 Main
> 10 1025 York
> I have struggled with this for a while and know there must be a simple
> method to achieve this result.
for line in input_lines:
fields = line.split()
farm_id = fields[0]
address_num = fields[1]
address_name = ' '.join(fields[2:])
--
John Gordon Imagine what it must be like for a real medical doctor to
gordon at panix.com watch 'House', or a real serial killer to watch 'Dexter'.
More information about the Python-list
mailing list