473,473 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sum operation on list if dictionary based on key.

1 New Member
I have a list of dictonary
[
{'code': 'L02', 'name': 'CREW SUPERVISOR', 'qty': 1},
{'code': 'L03', 'name': 'DRIVER', 'qty': 1},
{'code': 'L04', 'name': 'LABOURER', 'qty': 5},
{'code': 'L02', 'name': 'CREW SUPERVISOR', 'qty': 1},
{'code': 'L03', 'name': 'DRIVER', 'qty': 1},
{'code': 'L04', 'name': 'LABOURER', 'qty': 5},
{'code': 'L02', 'name': 'CREW SUPERVISOR', 'qty': 1},
{'code': 'L03', 'name': 'DRIVER', 'qty': 1}
]

I need a result like [{'code': 'L02', 'name': 'CREW SUPERVISOR', 'qty': 3},{'code': 'L03', 'name': 'DRIVER', 'qty': 3},{'code': 'L04', 'name': 'LABOURER', 'qty': 10}]

How can I achieve this?
Jul 19 '18 #1
0 1183

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
4
by: Martin Widmer | last post by:
Hi folks. I am using this collection class: Public Class ContentBlocksCollection Inherits DictionaryBase 'Object variables for attributes 'Attributes Default Public Property Item(ByVal...
1
by: georgehernando | last post by:
I am looking for an efficient way to delete the elements of a Python dictionary based on an evaluation of the element's value. Delete all elements with value bigger than x. Thanks
10
by: Petr Jakeš | last post by:
I have a standard 12-key mobile phone keypad connected to my Linux machine as a I2C peripheral. I would like to write a code which allows the text entry to the computer using this keypad (something...
8
by: Brian L. Troutwine | last post by:
I've got a problem that I can't seem to get my head around and hoped somebody might help me out a bit: I've got a dictionary, A, that is arbitarily large and may contains ints, None and more...
3
by: psbasha | last post by:
Hi, Is it mandatory to clear the data from the List ,Dictionary and Tuples after using it?. - PSB
5
by: cLoque | last post by:
Hi, I would like to know how to create a dictionary based matrix. Where column and row are considered in placing my desired value. and will pass value as dictionary just like this def...
2
vikas251074
by: vikas251074 | last post by:
I am creating an application for official use. This application will be used by employees to take items for official use. I have a list, presently this list contains three items - 1) Cartridges, ...
2
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I'm pulling records from or database by dates, and there are multiple records for each part number. The part numbers are being stored as strings in a List in a custom Employee class: ...
1
by: amel86 | last post by:
hello.. i have a question about how to make dependent list menu based on mysql? actually, i already found some code that helped me a lot but there has a problem that is i want to change 'get'...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.