I read these questions:
- csv data to nested json tree in d3
- Create a json tree from csv list in python
- How to Create a JSON Tree from a Tabulated Hierarchy in Python
- Python csv to nested JSON [closed]
However I'm still not able to convert a csv file to a hierarchy for JSON. Al the scripts I found on stackoverflow are specific for a certain problem. Let's say there are three variables which has to be grouped:
condition target sub
oxygen tree G1
oxygen tree G2
water car G3
water tree GZ
fire car GTD
oxygen bomb GYYS
This will result in a JSON file like this (as far as I tried):
oxygen
- tree
- G1
- G2
- bomb
-GYYS
water
- car
- G3
- tree
-GZ
fire
- car
- GTD
And these have to be grouped in a nested structure like:
{
"name": "oxygen",
"children": [
{
"name": "tree",
"children": [
{"name": "G1"},
{"name": "G2"},
{"name": "GYYS"}
]
},
{
"name": "bomb",
"children": [
{"name": "GYYS"}
]
}
]
}
etc.
I tried every script on this site however I'm not able to make a generic function which can make a flare.json like that. I can post my code however this is just like the links provided above. So I'm asking for a simple code (or an example which can help me) to convert this to a flare.JSON like structure.