title: python: split and create json data from csv
body: <p>How do I create a nested field from csv to json? I looked at the other stackoverflow, but they are not quite what I am trying to format. I have a data set with 1 column that I have to convert into a nested field. </p>
  
  <p>Data:</p>
  
  <pre><code>ID, NAME
  1, "Smith, Mr. Adams"
  2, "McAdams, Mrs. Audrey"
  3, "McAdams, Doctor John"
  4, "Missing Value"
  </code></pre>
  
  <p>CODE: </p>
  
  <pre><code>with open('test.csv', 'r') as file:
              headers = next(file) #skip the headers
              fieldnames = headers.rstrip().split(",")
              csv_reader = csv.DictReader(file, fieldnames) #creating a dictionary
              import datetime
              for row_dict in csv_reader:
                  row_dict['name'] = row_dict['name'].split(",")
                  json_data = json.dumps(row_dict)
                  print(json_data)
  </code></pre>
  
  <p>I am getting output in a list but it is not nested.</p>
  
  <pre><code>{"id": "1", "name": ["Smith", " Mr. Adams"]}
  {"id": "2", "name": ["McAdams", " Mrs. Audrey"]}
  {"id": "3", "name": ["McAdams", " Doctor John"]}
  {"id": "4", "name": ["Missing Value"]}
  </code></pre>
  
  <p>Final output: Is there any way to do this?</p>
  
  <pre><code>{"id": "1", "name": [{"last_name": "Smith",
                        "prefix": "Mr.",
                        "first_name":  "Adams"}]}
  {"id": "1", "name": [{"last_name": "McAdams",
                        "prefix": "Mrs.",
                        "first_name":  "Audrey"}]}
  {"id": "1", "name": [{"last_name": "McAdams",
                        "prefix": "Dr.",
                        "first_name":  "John"}]}
  {"id": "1", "name": [{"last_name": "Missing Value",
                        "prefix": "Missing Value",
                        "first_name":  "Missing Value"}]}                   
  </code></pre>