79642925

Date: 2025-05-28 20:06:52
Score: 1.5
Natty:
Report link

unless i misunderstand, looks like you just need to restructure your result differently.

const result = {};
for (let i = 7; i < jsonData.length; i++) {
    const rowData = jsonData[i];
    const singleRow = {};
    singleRow.water = { total: rowData[2], startDate: rowData[6]; }; // add other data as needed
    singleRow.electricity = { total: rowData[14], startDate: rowData[19]; };
    singleRow.gas = { total: rowData[9], startDate: rowData[11]; };

    const date = rowData[0];
    result[date] = singleRow;  // set property as row date
}

it seems you have all the pieces you need already. is there a particular issue you are having?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: sparkJ