Preview:
/* 
Range to Associative Array
PASS: Range with headers in the first row
RETURNS: Associantive array using header row as property names
Skips rows with nothing in the date column so we don't import the totals 
*/
function rangeToAssocArray(rng) {
  var result = [{}];
  // var sheet = SpreadsheetApp.getActiveSheet();
  // var rng = sheet.getRange(1, 1, sheet.getLastRow(), 8);
  var rngData = rng.getValues();

  if (rngData.length > 1) {
      for (let r = 1; r < rngData.length; r++) {
        if (rngData[r][0] != "") {
          result.push({});
          for (let c = 0; c < rngData[0].length; c++) {
            result[r][rngData[0][c]] = rngData[r][c];
          }
        }
      }
      result.shift();
  } else {
    //result = null;
  }
  return result;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter