Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64477
| Date | 2014-01-21 21:03 -0600 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: Separate Address number and name |
| References | <9fe1b47b-65ce-4063-9188-07b81cdba49f@googlegroups.com> <lbnbdn$69j$1@reader1.panix.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5828.1390359774.18130.python-list@python.org> (permalink) |
On 2014-01-22 02:46, John Gordon wrote:
> > FarmID AddressNum AddressName
> > 1 1067 Niagara Stone
> > 2 4260 Mountainview
> > 3 25 Hunter
> > 4 1091 Hutchinson
>
> > 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:])
Or, you can split of just the parts you need:
for line in input_lines:
farm_id, street_no, street_name = line.split(None, 2)
It doesn't address the issues that Ben raised about the crazy formats
you can find in addresses, but address-parsing is an twisty maze of
passages all alike.
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Separate Address number and name Shane Konings <shane.konings@gmail.com> - 2014-01-21 15:49 -0800
Re: Separate Address number and name Anders Wegge Keller <wegge@wegge.dk> - 2014-01-22 00:55 +0100
Re: Separate Address number and name Shane Konings <shane.konings@gmail.com> - 2014-01-21 16:01 -0800
Re: Separate Address number and name Shane Konings <shane.konings@gmail.com> - 2014-01-21 16:06 -0800
Re: Separate Address number and name Anders Wegge Keller <wegge@wegge.dk> - 2014-01-22 02:04 +0100
Re: Separate Address number and name Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-22 10:08 +0000
Re: Separate Address number and name Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-22 17:35 +0000
Re: Separate Address number and name Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-23 18:11 +0000
Re: Separate Address number and name Asaf Las <roegltd@gmail.com> - 2014-01-21 16:08 -0800
Re: Separate Address number and name Ben Finney <ben+python@benfinney.id.au> - 2014-01-22 11:08 +1100
Re: Separate Address number and name John Gordon <gordon@panix.com> - 2014-01-22 02:46 +0000
Re: Separate Address number and name Tim Chase <python.list@tim.thechases.com> - 2014-01-21 21:03 -0600
Re: Separate Address number and name Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-22 15:40 +0000
csiph-web