parsing tabs in a string

Mark McEahern marklists at
Mon Sep 23 13:18:36 EDT 2002

[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