3 ms·
Something that I've used in the past: store the hierarchical data as a breadcrumb-like string in an ordinary column. This means the parsing is just ordinary csv
by siddboots 8y ago
Something that I've used in the past: store the hierarchical data as a breadcrumb-like string in an ordinary column. This means the parsing is just ordinary csv parsing, followed by a relatively trivial extra step to parse the breadcrumb columns. You also retain the ability to describe arbitrary depth hierarchies:
country,value
World/Asia/China, 1409517397
World/Asia/India, 1339180127
World/Asia/Indonesia, 263991379
An added benefit of this approach is that you can have hierarchies in multiple columns. For example:
datetime, source_account, destination_account, amount
2016-07-01, Assets/ProjectFunding, Assets/Capital/Delivery, 134.2
2017-07-01, Assets/ProjectFunding, Assets/Capital/Delivery, 72.2
2016-07-01, Assets/ProjectFunding, Assets/Capital/Other, 5.0
2016-07-01, Assets/ProjectFunding, Expenses/Development, 4.7
2017-07-01, Assets/ProjectFunding, Expenses/Development, 1.6
2017-07-01, Assets/Cash, Expenses/OPEX, 0.96
2018-07-01, Assets/Cash, Expenses/OPEX, 1.62
- kqr 8y agoThat has the meta-problem of only allowing two different levels of hierarchies. For one more, you'd have to introduce a new separator. I feel like the fixpoint of this function is going back to only one separator, or something, but I am not seeing the reasoning clearly.