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 -- https://mail.python.org/mailman/listinfo/python-list