v
reader = csv.reader(open('testfile.txt'))
for ct,row in enumerate(reader):
print "var2=", row[2]
if ct>2:
break
The comma separated list parser in pyparsing is also great for this,
particularly when the input gets dirtier:
http://pyparsing.wikispaces.com/space
p('variable'), var.group
('value'))
:
:
x1 = 0.5
But I'm betting these files get more complex than just the snippet you
included, in which case it's probably worth looking at pyparsing
http://pyparsing.wikispaces.com/ and regular expressions.
--
Travis Brady
http://travisbrady.com/
--
http://mail.python.org/mailman/listinfo/python-list