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
#11
Of course it doesn't - your instance checks are for dicts, lists and strings and an object of type Foo for example is not one of those things. Where did this problem come from? Is this really the right kind of structure for the data?
Reply
#12
(Mar-08-2020, 04:55 PM)ndc85430 Wrote: Of course it doesn't - your instance checks are for dicts, lists and strings and an object of type Foo for example is not one of those things. Where did this problem come from? Is this really the right kind of structure for the data?

This structure was given to me. Hence, I need to work with what I have and search through this structure as it is. Independent of whether it is good or bad. Is there a possibility of reading this part of the dictionary too without restructuring the data?
Reply
#13
Well of course. You can call whatever methods you need on those objects, or check the fields you need when you encounter them and then process the values in the same way you're doing elsewhere.

Who would set up a problem like this though?!
Reply
#14
(Mar-08-2020, 06:33 PM)ndc85430 Wrote: Well of course. You can call whatever methods you need on those objects, or check the fields you need when you encounter them and then process the values in the same way you're doing elsewhere.

Who would set up a problem like this though?!

Can you give me some pointers on how to search through these objects to find the variable that contains the string I am looking for?

Who is not important I think, it is more that this is all I have and if there is a solution, I would like to know.
Reply
#15
I'm not sure what you mean by search - just call the relevant methods, or check the values of whatever fields.
Reply
#16
(Mar-08-2020, 07:15 PM)ndc85430 Wrote: I'm not sure what you mean by search - just call the relevant methods, or check the values of whatever fields.

I ment that I need to look for a certain keyword in a dictionary with one of the dictionary entries being the "checking.check.assessment" object but, how do I get access to it and 'search' through this object for the keyword while going through the recursive loop. Or am I missing something...
Reply
#17
The same way you're doing with anything else - you can check whether the value is of that type and if so, do what you need with it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Comparing items from 2 lists of dictionaries illwill 7 533 Sep-14-2020, 10:46 PM
Last Post: bowlofred
  Searching through Nested Dictionaries and Lists Dave_London 1 530 Jul-09-2020, 03:36 PM
Last Post: mrdominikku
  Creating Nested Dictionaries Confusion gw1500se 2 647 May-18-2020, 11:16 PM
Last Post: gw1500se
  Unpacking nested lists yonatan776 1 633 Apr-14-2020, 08:50 PM
Last Post: buran
  Help: for loop with dictionary and nested lists mart79 1 699 Apr-12-2020, 02:52 PM
Last Post: TomToad
  nested dictionaries to CSV mart79 9 5,117 Jul-29-2019, 04:59 AM
Last Post: mart79
  Transform simplified dictionary to nested dictionaries bhojendra 1 829 Jul-02-2019, 02:05 PM
Last Post: ichabod801
  Help to flatten list of nested dictionaries shawbapmp 4 2,690 Feb-25-2019, 10:18 PM
Last Post: shawbapmp
  Nested Dictionaries with Lists BriHaug 1 1,073 Feb-23-2019, 02:10 AM
Last Post: ichabod801
  Help with Dictionaries and List of Lists artblinked 7 1,167 Feb-14-2019, 05:07 PM
Last Post: artblinked

Forum Jump:

User Panel Messages

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