I have a question. I tried to put together information from other questions but with no success. Assume I have data in the following format:
file_list = ["f1", "f2", "f3"]
inner_dict = {1: "one", 2: "two", 3: "three"}
outer_dict = {}
for f in file_list:
outer_dict[f] = inner_dict
My aim is to print (to be saved into a file) in the following way:
f1, 1, one
f1, 2, two
f1, 3, three
f2, 1, one
f2, 2, two
f2, 3, three
f3, 1, one
f3, 2, two
f3, 3, three
To this aim, I started focusing on the items of outer_dict
, and I managed to print them separately, but I am not sure how to further join (and, more importantly, if this is the most direct way to go).
for key, value in outer_dict.items():
inn_keys = value.keys()
inn_values = value.values()
b1 = "\n".join([str(x) for x in inn_keys] )
b2 = "\n".join([str(x) for x in inn_values] )
Thanks for any suggestions.