Python Forum
Finding value in nested dictionaries with lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding value in nested dictionaries with lists
#1
I am struggling with finding a value within a dictionary containing nested dictionaries which in turn can contain nested dictionaries, containing lists etc. The value, to be found, can be anywhere, so within a nested dictionary in a nested dictionary in a list, but also within a list within a nested dictionary or just a list. If the value is found more than once, I also want to know the name of the dictionary to which it belongs.

For example: If the value is found in a list and that list belongs to a nested dictionary, I want to know the name of that nested dictionary.

Unfortunately, I am not able to give you an example. Can you give me some pointers who I could solve this problem?

I have thought about it:
Would flatten the dictionary be an option and look trough the values to see if they match and then return their respective keys? The problem is that I do not know how to flatten complex nested dictionaries....
Reply


Messages In This Thread
Finding value in nested dictionaries with lists - by mart79 - Mar-07-2020, 08:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List all possibilities of a nested-list by flattened lists sparkt 1 915 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,368 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Comparing items from 2 lists of dictionaries illwill 7 2,756 Sep-14-2020, 10:46 PM
Last Post: bowlofred
  Searching through Nested Dictionaries and Lists Dave_London 1 7,417 Jul-09-2020, 03:36 PM
Last Post: mrdominikku
  Creating Nested Dictionaries Confusion gw1500se 2 2,133 May-18-2020, 11:16 PM
Last Post: gw1500se
  Unpacking nested lists yonatan776 1 2,199 Apr-14-2020, 08:50 PM
Last Post: buran
  Help: for loop with dictionary and nested lists mart79 1 1,864 Apr-12-2020, 02:52 PM
Last Post: TomToad
  nested dictionaries to CSV mart79 9 12,443 Jul-29-2019, 04:59 AM
Last Post: mart79
  Transform simplified dictionary to nested dictionaries bhojendra 1 2,367 Jul-02-2019, 02:05 PM
Last Post: ichabod801
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,264 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020