I need to parse CSV in power automate so that I find one value and update a table accordingly. I have done a lot of testing.
At the moment, the best working technique is that but I can't get it to work because it's in JavaScript, and I dont know it!
The whole process that I'm taking is like this:

function main(workbook: ExcelScript.Workbook,
csvData: string) {
var lines = csvData.split("\n");
var result = [];
var headers = lines[0].split(",");
for (var i = 1; i < lines.length; i++) {
var obj = {};
var currentline = lines[i].split(",");
for (var j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
console.log(result.toString());
return JSON.stringify(result);
}
By headers are at lines 6 so I have extra stuff on top that I dont need but the JSON that I get at the end doesn't look alright. I have tested a few times and I know that it's caused by the JavaScript script. As you can see below, the INPUT of RUN SCRIPT is all find with my header sitting at line 6 (static). but the OUTPUT which is generated by that script doesn't look JSON. my header consists of 2 values only, so should my data!

Thanks in advance for you help!
_________ Original CSV sample:

Customer Sales,
Custom Sales by Customer Summary,
1 September 2021 - 30 September 2021,
,
,
Region: Name (Grouped) ,Sales
,"$12,161"
NSW / ACT,$280
SA,$801
NSW / ACT,-$35
VIC,$116
SA,$94
NSW / ACT,$298
WA,$55
SA,$903
VIC,$478
NSW / ACT,$222
Total,"$97,551"
expected output is like this: {total}={'$97,551}