En Wed, 06 Feb 2008 01:52:08 -0200, Gabriel Genellina <[EMAIL PROTECTED]> escribió:
> I have a text file with marked up data that I need to convert into a > text tab separated file. Sorry, I sent the code too early: rows = [] row = None for line in file1: line = line.strip() # remove leading and trailing whitespace if line.startswith('<item>'): if row: rows.append(row) j = line.index("</") item = line[6:j] row = [item] elif line.startswith('<color>'): j = line.index("</") color = line[7:j] row.append(color) else: raise ValueError, "can't understand line: %r" % line if row: rows.append(row) (some `row` should have been `line`) In the second part, the right dialect name is 'excel-tab' instead of 'excel_tab'. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list