title: Convert CSV to nested JSON
body: <p>I am trying to convert following CSV to JSON below. Any help will be appreciated.</p>
  
  <p>Sample of CSV file (File would contain lot of network groups with network,host attributes)</p>
  
  <pre><code>Type,Value ,Name
  Network,10.0.0.0/8,network_group_3
  Host,10.0.0.27,network_group_3
  Host,10.0.0.28,network_group_3
  Network,10.10.10.0/24,network_group_4
  Network,10.10.20.0/24,network_group_4
  Host,10.10.10.6,network_group_4
  </code></pre>
  
  <p>Output in JSON Needed </p>
  
  <pre><code>netgroup =
   "literals": [
      {
        "type": "Network",
        "value": "10.0.0.0/8"
      },
      {
        "type": "Host",
        "value": "10.0.0.27"
      },
      {
        "type": "Host",
        "value": "10.0.0.28"
      }
    ],
    "name": "network_group_3"
  },
  { 
   "literals": [
      {
        "type": "Network",
        "value": "10.10.10.0/24"
      },
      {
        "type": "Network",
        "value": "10.10.20.0/24"
      },
      {
        "type": "Host",
        "value": "10.0.0.6
      }
    ],
    "name": "network_group_4"
  </code></pre>