Stephen Hansen <me+list/pyt...@ixokai.io> wrote: >On 6/28/10 10:29 AM, Ken D'Ambrosio wrote: >> for line in file: >> match = re.search((seek)",(.*),(.*)", line) # Stuck here > [ ... ] > name, foo, bar = line.split(",") > if seek in name: > # do something with foo and bar > >That'll return True if the word 'seek' appears in the first field of >what appears to be the comma-delimited line.
If the file input is comma-delimited, then the OP might very well want a look at the csv module. Something like: for line in reader(file): if line[0] == seek: # first field matches, do something with line[-1] and line[-2] # -- I'm not quite sure what the semantics of a pair of greedy # (.*)s would be -- \S under construction -- http://mail.python.org/mailman/listinfo/python-list