title: get column names and its values in object where values for Column1 are dynamic
body: <p>I have a following kind of spreadsheet where there are two columns but the number of rows where user can able to input value can be dynamic. I mean user might input 10 values for sub-column1 or 20. When user hits the submit button after filling the data, the script should create the following object</p>
  
  <pre><code>"data": {
      "Column1": [
          {
              subcolumn1: 100,
              subcolumn2: 200,
              subcolumn3: 300
          },
          {
              subcolumn1: 400,
              subcolumn2: 500,
              subcolumn3: 600
          },
          {
              subcolumn1: 700,
              subcolumn2: 800,
              subcolumn3: 900
          },
      ],
      "Column2": {
          column2a: 100,
          column2b: 20
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/l7l78.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l7l78.png" alt="enter image description here"></a></p>
  
  <p>for now, i could only get the sheet using app script</p>
  
  <pre><code>function testCalculation() {
    var app = SpreadsheetApp;
    var sheet = app.getActiveSpreadsheet();
    var activeSheet = sheet.getSheetByName("Sheet1");
    var column = 2;
    var lastRow = activeSheet.getLastRow();
    var lastColumn = activeSheet.getLastColumn();
    var searchRange = activeSheet.getRange(4, 1, lastRow-4+1, lastColumn);
    var rangeArray = searchRange.getValues();
    var data = rangeArray;
    var headers = data.shift();
    Logger.log(headers);
    var result = {}
    var subHeaders = data.shift();
    var row = [];
    var finalResult = [];
    for (var i = 0, l = data.length; i &lt; l; i++) {
      Logger.log(data[i]);
      row=data[i];
      result = {}
      for (var col=0; col &lt; subHeaders.length; col++ ) { 
        result[subHeaders[col]] = row[col]
      }
      finalResult.push(result);
    }
    Logger.log(finalResult);
  }
  </code></pre>
  
  <p>here is the spreadsheet</p>
  
  <p><a href="https://docs.google.com/spreadsheets/d/1534Nf5Mr-kivX-swcqdganNza6EtwDIps9nOzJhjzWc/edit#gid=0" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1534Nf5Mr-kivX-swcqdganNza6EtwDIps9nOzJhjzWc/edit#gid=0</a></p>
  
  <p>UPDATE</p>
  
  <p>I am getting the following object now</p>
  
  <pre><code>[
    {
      "subcolumn1": 100,
      "subcolumn2": 200,
      "subcolumn3": 300,
      "column2a": 100,
      "column2b": 20
    },
    {
      "subcolumn1": 400,
      "subcolumn2": 500,
      "subcolumn3": 600,
      "column2a": "",
      "column2b": ""
    },
    {
      "subcolumn1": 700,
      "subcolumn2": 800,
      "subcolumn3": 900,
      "column2a": "",
      "column2b": ""
    }
  ]
  </code></pre>
  
  <p>Sorry, the access was private before but now it is public.</p>
  
  <p>how can i create above object now?</p>