title: d3.js how to generate tree hierarchy from csv or table
body: <p>I have a csv with the following data:</p>
  
  <pre><code>world,country,state
  
  World,US,CA
  
  World,US,NJ
  
  World,INDIA,OR
  
  World,INDIA,AP
  </code></pre>
  
  <p>I need to convert in to a tree hierarchy as shown below:</p>
  
  <pre><code>{
  
  "name": "World",
  "children": [
    { "name": "US",
        "children": [
         { "name": "CA" },
         { "name": "NJ" }
       ]
    },
    { "name": "INDIA",
        "children": [
        { "name": "OR" },
        { "name": "TN" }
       ]
    }
  </code></pre>
  
  <p>]
      };</p>
  
  <p>Using d3.nest I can only get to an json array, not a tree with the name 'children' in it. Anything additional I need to do? Reading API didn't really help, and I can't find a snippet of code that does the conversion anywhere I searched.</p>