Best tool to generate specific graph from Python dict/JSON

I'm looking to make a specific graph layout from a specific **format** of **Python** data, but where the **data may be text, string, or another Python object**.

It has to be able to do it on the **fly**, and make visual formatting decisions based on whether the data is "the same" (regardless of numerically, text or another Python object).

It doesn't matter if Excel is used to make the image (*.xls or .csv) or ```matplotlib```or anything else.

***The coloring in the cells*** is based on whether the items within ```{1:"A", 2:"A"}```are **equivalent** (not the same object). **Green** for ```True```, **red** for ```False```. For example: ```"A" == "A"``` (as in the preceding sentences), or ```(10/5) == (20/10)```, or ```["A", 1, <test object at 0x1052c9b70>] == ["A", 1, <test object at 0x1052c9b70>]``` would all be green.

The text that appears in the cells is just the \__str__ representation of the object.

EDIT: I'm not so much looking for someone to do the work for me, but a recommendation of which tool (```XLS```, ```matplotlib```, ```whathaveyou```) would be best suited - and maybe a link to a tutorial on how to do some of those more difficult features (like the cell coloring).

I.e. ...
   
    {
        1000:{
              "Sample1":{1:"A", 2:"A"},
              "Sample2":{1:"A", 2:"A"},
              "Sample3":{1:"A", 2:"A"},
              },

        1001:{
              "Sample1":{1:"A", 2:"A"},
              "Sample2":{1:"A", 2:"A"},
              "Sample3":{1:"A", 2:"A"}
              },

        1002:{
              "Sample1":{1:"C", 2:"A"},
              "Sample2":{1:"A", 2:"A"},
              "Sample3":{1:"A", 2:"A"}
              },

        (...)

        9999:{
              "Sample1":{1:"A", 2:"T"},
              "Sample2":{1:"A", 2:"A"},
              "Sample3":{1:"A", 2:"G"}
              },
    }

Excel Example
LVL 3
Mike R.Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Flabio GatesCommented:
perhaps with the help of xlsxwriter
import xlsxwriter

data = {
    1000:{
        "Sample1":{1:"A", 2:"A"}, 
        "Sample2":{1:"A", 2:"A"},
        "Sample3":{1:"A", 2:"A"},
    },
    1001:{
        "Sample1":{1:"A", 2:"A"}, 
        "Sample2":{1:"A", 2:"A"},
        "Sample3":{1:"A", 2:"A"}
    },
    1002:{
        "Sample1":{1:"C", 2:"A"}, 
        "Sample2":{1:"A", 2:"A"},
        "Sample3":{1:"A", 2:"A"}
    },
    9999:{
        "Sample1":{1:"A", 2:"T"}, 
        "Sample2":{1:"A", 2:"A"},
        "Sample3":{1:"A", 2:"G"}
    },
}



workbook = xlsxwriter.Workbook('foo.xlsx')
worksheet = workbook.add_worksheet()

greenbg = workbook.add_format({'bg_color': '#80FF80'})
redbg = workbook.add_format({'bg_color': '#FF8080'})
##greenbg = workbook.add_format({'bg_color': '#008000'})
##redbg = workbook.add_format({'bg_color': '#800000'})

worksheet.write(0, 1, "Sample1")
worksheet.write(0, 2, "Sample2")
worksheet.write(0, 3, "Sample3")

r = 1
for k in sorted(data):
    d = data[k]
    worksheet.write(r, 0, k)
    for i, kk in enumerate(sorted(d)):
        dd = d[kk]
        value = '%s/%s' % (dd[1], dd[2])
        format = greenbg if dd[1]==dd[2] else redbg
        worksheet.write(r, 1+i, value, format)
        
    r+=1

workbook.close()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.