This is my data:
2018-06-19 136768197 e230702d
2018-06-19 136768197 f14c4f07
2018-06-15 1157040118 a527b130
2018-06-15 1157040118 f05a746f
As output I need the following dict
{
'2018-06-19': {
'136768197': ['e230702d', 'f14c4f07']
},
'2018-06-15': {
'1157040118': ['a527b130', 'f05a746f']
}
}
My attempt to resolve the problem:
d = defaultdict(list)
c = dict()
with open("c:/Python/hitId.txt") as f:
for line in f:
key, s, h = line.split()
d[s].append(h)
c[key] = d
But the output contains duplicated data (formatted to highlight issue):
{'2018-06-15': {'1157040118': ['a527b130', 'f05a746f'],'136768197': ['e230702d', 'f14c4f07']}),
'2018-06-19': {'1157040118': ['a527b130', 'f05a746f'],'136768197': ['e230702d', 'f14c4f07']})}