Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
Converting CSV to JSON using JAVASCRIPT (as a step of power automate)

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: enter image description here

  1. I read the csv from sharepoint where I save it
  2. I COMPSOSE it to have a clean data
  3. I ran that against an OFFICE AUTOMATE script which is in JavaScript lanaguage (see below) to produce JSON so that I can get the value I want easily:
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! enter image description here

Thanks in advance for you help!

_________ Original CSV sample: enter image description here

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}


about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!