title: Python: Converting excel file to JSON format
body: <p>I am creating a ML model that will use a JSON file to understand the pattern and response format. As I have my data in excel format I converted it to JSON in python.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import xlrd
  from collections import OrderedDict
  import simplejson as json
  # Open the workbook and select the first worksheet
  wb = xlrd.open_workbook('D:\\android\\testdata2.xlsx')
  sh = wb.sheet_by_index(0)
  # List to hold dictionaries
  data_list = []
  # Iterate through each row in worksheet and fetch values into dict
  for rownum in range(1, sh.nrows):
      data = OrderedDict()
      row_values = sh.row_values(rownum)
      data['pattern'] = row_values[0]
      data['response'] = row_values[1]
      data_list.append(data)
  # Serialize the list of dicts to JSON
  j = json.dumps(data_list)
  # Write to file
  with open('data1.json', 'w') as f:
      f.write(j)
  </code></pre>
  
  <p>I am the getting the output as:</p>
  
  <pre><code>[{
      "pattern": "WALLSTENT NON COUVERTE ",
      "response": "ENDOPROTHESE STENT  VASCULAIRE "
  }, {
      "pattern": "PRIMEADVANCED SURSCAN MRI ",
      "response": "NEUROSTIMULATEUR NERF VAGUE GAUCHE "
  }, {
      "pattern": "AVASTIN  FLACON DE",
      "response": "BEVACIZUMAB"
  }, {
      "pattern": "PERJETA SOLUTION A DILUER POUR PERFUSION",
      "response": "BRENTUXIMAB VEDOTIN"
  }]
  </code></pre>
  
  <p>The desired output I am looking for is like this:</p>
  
  <pre><code>{
      "intents": [{
          "pattern": ["WALLSTENT, NON, COUVERTE "],
          "response": ["ENDOPROTHESE STENT  VASCULAIRE] "
      }, {
          "pattern": ["PRIMEADVANCED ,SURSCAN ,MRI"] ,
          "response": ["NEUROSTIMULATEUR NERF VAGUE GAUCHE "]
      }, {
          "pattern": ["AVASTIN , FLACON ,DE"],
          "response": ["BEVACIZUMAB"]
      }, {
          "pattern": ["PERJETA, SOLUTION, A, DILUER, POUR ,PERFUSION"],
          "response": ["BRENTUXIMAB VEDOTIN"]
      }]
  }
  </code></pre>
  
  <p>What modification can I do in my function to get the output I am looking for.</p>