Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.068 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'subject:number': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'line.split()': 0.16; 'need:': 0.16; 'wrote:': 0.18; 'result.': 0.19; 'split': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; "skip:' 10": 0.31; 'raised': 0.31; 'but': 0.35; 'there': 0.35; 'addresses,': 0.36; 'crazy': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'ben': 0.38; 'john': 0.61; 'simple': 0.61; 'address': 0.63; 'hunter': 0.84; 'hutchinson': 0.84; 'received:50.22': 0.84; 'stone': 0.84; 'to:addr:gordon': 0.84 Date: Tue, 21 Jan 2014 21:03:42 -0600 From: Tim Chase To: John Gordon Subject: Re: Separate Address number and name In-Reply-To: References: <9fe1b47b-65ce-4063-9188-07b81cdba49f@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390359774 news.xs4all.nl 2850 [2001:888:2000:d::a6]:46621 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64477 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