title: Convert csv to JSON tree structure?
body: <p>I read these questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/19043561/csv-data-to-nested-json-tree-in-d3">csv data to nested json tree in d3</a></li>
  <li><a href="https://stackoverflow.com/questions/12616229/create-a-json-tree-from-csv-list-in-python">Create a json tree from csv list in python</a></li>
  <li><a href="https://stackoverflow.com/questions/7408615/how-to-create-a-json-tree-from-a-tabulated-hierarchy-in-python">How to Create a JSON Tree from a Tabulated Hierarchy in Python</a></li>
  <li><a href="https://stackoverflow.com/questions/35969611/python-csv-to-nested-json">Python csv to nested JSON [closed]</a></li>
  </ul>
  
  <p>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:<br></p>
  
  <pre><code>condition   target  sub
  oxygen      tree    G1
  oxygen      tree    G2
  water       car     G3
  water       tree    GZ
  fire        car     GTD
  oxygen      bomb    GYYS
  </code></pre>
  
  <p>This will result in a JSON file like this (as far as I tried):</p>
  
  <pre><code>oxygen
      - tree  
          - G1
          - G2
      - bomb
          -GYYS
  water 
      - car
          - G3
      - tree
          -GZ
  fire 
      - car   
          - GTD
  </code></pre>
  
  <p>And these have to be grouped in a nested structure like:</p>
  
  <pre><code>    {
     "name": "oxygen",
     "children": [
      {
       "name": "tree",
       "children": [
        {"name": "G1"},
        {"name": "G2"},
        {"name": "GYYS"}
       ]
      },
      {
       "name": "bomb",
        "children": [
        {"name": "GYYS"}
       ]
      }
      ]
  }
  etc.
  </code></pre>
  
  <p>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. </p>