title: Convert csv tree structure to json
body: <p>I have a large excel document (2000+ lines) that uses the cells to specify a tree structure and I would like to parse that into a .json file. The excel-exported .csv document is formatted as follows, where in the excel file a comma would be an empty cell:</p>
  
  <blockquote>
    <p>Layer1category1,,,,,</p>
    
    <p>,Layer2category,,,,</p>
    
    <p>...</p>
    
    <p>,,,,Layer5category1,</p>
    
    <p>,,,,,item1</p>
    
    <p>,,,,,item2</p>
    
    <p>,,,,Layer5category2,</p>
    
    <p>,,,,,item1</p>
    
    <p>,,,Layer4category2,,</p>
    
    <p>...</p>
    
    <p>Layer1category2,,,,,</p>
    
    <p>...</p>
    
    <p>Layer1category8,,,,,  // this is the last category in the uppermost layer</p>
  </blockquote>
  
  <p>In summary, Layer <em>n</em> categories are prefaced with <em>n-1</em> commas and followed by <em>6-n</em> commas, and rows prefaced with 5 commas are the final layer, which is in the format of a string and has many fields other than its name.</p>
  
  <p>I would like this to be converted to a .json file similar to the following. I use "name" because aside from a name each field is also tied to a lot of statistics that also needs to go into the json file.</p>
  
  <pre><code>{"name" : "Layer1category1",
   "children": [
      {"name" : "Layer2category1",
       "children" : [
          {"name" : "Layer3category1"
           "children" : [ 
              ...
                      {"name" : "Layer5category1",
                       "children" : [{"name" : "item1"}, {"name" : "item2"}],}
                      {"name" : "Layer5category2",
                       "children" : [{"name" : "item1"}],}
                  {"name" : "Layer4category2",
                   "children" : [
                  ...
                  ]}
  "name" : "Layer1category2",
  "children" : [ ... ]
  }
  </code></pre>
  
  <p>Does anyone have any suggestions for how I can approach this? The csv to json converters I have found do not support multi-layered structures. Thanks!</p>