Python Forum
dictionary of dictionaries, to be updated
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dictionary of dictionaries, to be updated
#1
i have a dictionary of dictionaries. and i have another one to update the first one with on an individual item-by-item basis. it appears that dictodicts1.update(dictodicts2) is not really going to to this right. i suspect that for a subdictionary that is in both (has the same key in both dictodicts1 and dictodicts2), doing an update like that will replace one whole subdictionary with another whole subdictionary. bet i could be wrong about that. if i am right, does anyone know a good way to update the 1st from the 2nd on an individual item-by-item basis?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
What do you mean by “update”? Do you want add key-value pairs which are not in first dictionary or you want update value in first dictionary if key is in second dictionary?
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
i want to add whatever is not already there and replace whatever is there that the update object has, whether that is in the first level or second. if there is a case of more than one value in different dictionaries at the 2nd level but in the same dictionary at the first level, the result should be a combined entry. so the logic should work with leaf entries.

there is a situation that is going to be hard to deal with and that is where one source has a dictionary with one or more objects at any level conflicting with a non-dictionary object, which will force a decision to replace one or the other, with implications at the level below.

i'm wondering if flattening this to a list (could help) of key,reference 2-tuples where each key is an N-tuple based on how many levels down it is.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort a list of dictionaries by the only dictionary key Calab 1 452 Oct-27-2023, 03:03 PM
Last Post: buran
  Mysql Workbench table not updated CatBall 2 1,047 Feb-13-2023, 05:37 PM
Last Post: CatBall
  convert List with dictionaries to a single dictionary iamaghost 3 2,805 Jan-22-2021, 03:56 PM
Last Post: iamaghost
  live updated json file Nyanpasu 2 2,200 Aug-22-2020, 04:41 PM
Last Post: Nyanpasu
  Multiple items of a matrix has been updated. Yoki91 4 2,246 May-19-2020, 06:29 PM
Last Post: Yoki91
  Verify if .docx table of contents is updated as per document sections or not vintysaw 0 3,843 Oct-24-2019, 12:01 PM
Last Post: vintysaw
  Help with pyGenealogical-Tools (Updated) Matan_ran 5 107,241 Oct-16-2019, 08:48 PM
Last Post: Larz60+
  Transform simplified dictionary to nested dictionaries bhojendra 1 2,324 Jul-02-2019, 02:05 PM
Last Post: ichabod801
  Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV dn237 19 6,583 May-29-2019, 02:27 AM
Last Post: heiner55
  Updated security logger jameseroni 0 2,018 Oct-29-2018, 04:23 AM
Last Post: jameseroni

Forum Jump:

User Panel Messages

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