Dictionary of Dicts question

John Townsend jtownsen at adobe.com
Fri Oct 17 00:03:17 CEST 2008

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.

-----Original Message-----
From: python-list-bounces+jtownsen=adobe.com at python.org [mailto:python-list-bounces+jtownsen=adobe.com at python.org] On Behalf Of Dennis Lee Bieber
Sent: Thursday, October 16, 2008 2:44 PM
To: python-list at python.org
Subject: Re: Dictionary of Dicts question

On Thu, 16 Oct 2008 14:05:16 -0700, John Townsend <jtownsen at adobe.com>
declaimed the following in comp.lang.python:

> I have two text files. Each file contains data like this:
> Test file 1234 4567 8975
> I want to compare the numbers in each text file. The data set (i.e. the numbers) has a unique identifier: the "test" + the "file". The text files are similar, but may not be exactly the same.

        This would be easier if you gave a few lines sample from each file
and the expected output of your processing of those lines.

> My initial idea was to read the text files and turn each line into a dictionary entry. A dict for each text file. Then walk through the dicts and compare the numbers.
> If anyone has a better idea, I'd love to hear it.
        Use a relational database and "GROUP BY" selections?
        Wulfraed        Dennis Lee Bieber               KD6MOG
        wlfraed at ix.netcom.com           wulfraed at bestiaria.com
        (Bestiaria Support Staff:               web-asst at bestiaria.com)

More information about the Python-list mailing list