Mar-19-2018, 09:33 PM
Hey nilamo,
Thanks for that - I was able to achieve similar result by using defaultdict. After splitting key-values on colon I created and zipped two list with keys and corresponding values and then:
Thanks for that - I was able to achieve similar result by using defaultdict. After splitting key-values on colon I created and zipped two list with keys and corresponding values and then:
grouped = defaultdict(list) for key, val in record: grouped[key].append(val)But if I associate recurrent keys with all its values I cannot see the way of differentiating single records, say one from from 'a' to 'd' and second from 'a' to 'e'. How do you know if 'e' belongs to first or second record? All values will be clustered around single keys. My aim here is to construct JSON out of input data and I cannot see an easy way of producing that out of values grouped around single keys.