nukeymusic wrote: > thanks and also thanks to all the others who were so kind to help me > out with my first python-script. > I tested your alternatives and they work, the only a minor > inconvenience is that the first line of the inputfile gets lost i.e. > the first timestamp should become zero (seconds)
That should be easy to fix: >> with open('testfile','r') as f, open('outputfile','w') as g: >> first_date, first_rest = parse_line(next(f)) g.write("0 %s" % first_rest) >> for line in f: >> cur_date, rest = parse_line(line) >> delta = cur_date - first_date >> g.write("%s %s" % (int(round(delta.total_seconds())), rest)) -- http://mail.python.org/mailman/listinfo/python-list