On Oct 16, 11:03 pm, John Townsend <[EMAIL PROTECTED]> wrote: > Here are some sample lines. > > Text file 1 contains: > > DescribeImage AllAdjustments.psd 0.668000012636 0.046 0.426 > 0.06475 0.06475 0.005875 > DescribeImage All_Options_Multi.psd 0.552750021219 0.046 0.355875 > 0.01525 0.017125 0.0 > DescribeImage All_Options_Quad.psd 0.57025000453 0.046 0.314875 > 0.058375 0.058375 0.007875 > DescribeImage Apple_RGB.psd 0.538999974728 0.046 0.315 0.04675 > 0.04875 0.0 > > Text file 2 contains: > DescribeImage AllAdjustments.psd 0.7889 0.056 0.786 0.0665 > 0.06476 0.999 > DescribeImage All_Options_Multi.psd 0.5527500421419 0.43154312 > 0.4443 0.43124 0.017125 0.0 > DescribeImage All_Options_Quad.psd 0.5702503200453 0.046 0.34 > 0.058375 0.4342 0.43214 > > Lines are tab delimited. Note, in this example text file 2 contains three > lines, while text file 1 contains four lines. > > Where there are matching lines in each text file (e.g. "DescribeImage > AllAdjustments.psd" exists in both files), I want to compare each of the > numbers from that line to the numbers in the corresponding line. > > If there is not corresponding line (like " DescribeImage > Apple_RGB.psd"), skip the comparison test. > > I hope this helps describe my problem. > If the first 2 fields are unique when combined, then you could use that as the key:
data = {} for line in open(path): fields = line.split("\t") data[tuple(fields[ : 2])] = fields[2 : ] -- http://mail.python.org/mailman/listinfo/python-list