Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

329
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda