Create nested python dictionary

Create nested python dictionary

I am using the python code below to extract some values from an excel spreadsheet and then push them to an html page for further processing. I would like to modify the code below so that I can add additional values against each task, any help

I am using the python code below to extract some values from an excel spreadsheet and then push them to an html page for further processing. I would like to modify the code below so that I can add additional values against each task, any help

the code below does spit out the following:

{'line items': {'AMS Upgrade': '30667', 'BMS works': '35722'}}

How can I revise the code below so that I can add 2 more values against each task i.e. AMS Upgrade and BMS works and get the likes of (note the structure below could be wrong)

{'line items': {'AMS Upgrade': {'30667','100%', '25799'}},{'BMS works': {'10667','10%', '3572'}} }

Code:

book = xlrd.open_workbook("Example - supporting doc.xls")
first_sheet = book.sheet_by_index(-1)
nested_dict = {}
nested_dict["line items"] = {}

for i in range(21,175): Line_items = first_sheet.row_slice(rowx=i, start_colx=2, end_colx=8)

if str(Line_items[0].value) and str(Line_items[1].value):
    if not Line_items[5].value ==0 : 
        nested_dict["line items"].update({str(Line_items[0].value) : str(Line_items[1].value)})

print nested_dict print json.dumps(nested_dict)

*** as requested see excel extract below


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Guide to Python Programming Language

Guide to Python Programming Language