parsing tabs in a string

Andrew Alzner andrewa at calibredigital.com
Mon Sep 23 20:23:53 CEST 2002


Thanks everyone for the quick response! This helps out a lot. I will be
using the string.split to make it more manageable.

Andrew

----- Original Message -----
From: "Mark McEahern" <marklists at mceahern.com>
To: "Andrew Alzner" <andrewa at calibredigital.com>; <python-list at python.org>
Sent: Monday, September 23, 2002 1:18 PM
Subject: RE: parsing tabs in a string


> [Andrew Alzner]
> > I'm trying to parse information extracted from a spreadsheet
> > which is tab separated. Here is a simplified version of what I have:
> >
> > list=['"103-01a-17"\t2\t33\t256\t227\n']
> > y=list[0]
> > print y.find("\t")
> > print y.find("\t",1)
>
> Don't use list as a variable name, you'll stomp all over the builtin list.
> Rather than finding each tab, why not split on tabs:
>
> a = ['"103-01a-17"\t2\t33\t256\t227\n']
> y = a[0]
> for x in y.split("\t"):
>   print x
>
> // m
>





More information about the Python-list mailing list