Python Forum
Displaying duplicates in dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying duplicates in dictionary
#3
It's impossible to have with your code duplicates, because you're not creating duplicates.
I changed your code a litte bit (functionality is the same):

from pprint import pprint


src_base_path = "/data/infy"
year_mth = "2020-10-05"
folder_names = ["1", "2", "3"]
table_names = ["bt1", "bt2", "bt3"]

print(f"Tables to be processed: {table_names}")
print(f"Folders to be processed: {folder_names}")

src_path = "{0}/{1}/app_date={2}/source={3}/"
input_body = []
for folder_name in folder_names:
    for table_name in table_names:
        input_body.append(
            {
                "sourcePath": src_path.format(
                    src_base_path, table_name, year_mth, folder_name
                ),
                "tableName": table_name,
            }
        )


pprint(input_body)
A dict can have only unique keys. Putting stuff into a dict with the same key will overwrite the old value.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
Displaying duplicates in dictionary - by lokesh - Oct-15-2020, 07:45 AM
RE: Displaying duplicates in dictionary - by buran - Oct-15-2020, 08:06 AM
RE: Displaying duplicates in dictionary - by DeaD_EyE - Oct-15-2020, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove partial duplicates from csv ledgreve 0 906 Dec-12-2022, 04:21 PM
Last Post: ledgreve
  Removal of duplicates teebee891 1 1,889 Feb-01-2021, 12:06 PM
Last Post: jefsummers
  Dictionary iteration and creation a new dictionary from duplicates xrsxlnx 2 2,229 Mar-30-2020, 10:43 AM
Last Post: xrsxlnx
  Deleting duplicates in tuples Den 2 2,847 Dec-14-2019, 10:32 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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