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

193
Vistas
Reshape Unpivot Columns using Javascript

I have a requirement where I need to reshape data in a csv. Below is the csv

Set No       ;Res No        ;A     ;B    ;C     
1451         ;1123          ;0     ;1    ;2000  
1351         ;1133          ;0     ;2    ;3000  

And here is the desired output.

Set No     ;Res No      ;Attrib     ;Value     
1451       ;1123        ;A          ;0
1451       ;1123        ;B          ;1
1451       ;1123        ;C          ;2000
1351       ;1133        ;A          ;0
1351       ;1133        ;B          ;2
1351       ;1133        ;C          ;3000

I tried the below code but it is running an infinite loop

var text = a

var linearray = String(text).split("\r\n")
var len = linearray.length
for (var i=0; i<linearray.length-1;i++)

{

    var temparray = linearray[i].split(";")

    for(j = 0;j<temparray.length-1;j++)
{
       temparray.push([]);
}
     
    

    linearray[i] = temparray.join(";")

}


linearray.join("\r\n")

"a" in the code contains the value of the csv file. Can you please suggest what I am doing wrong and what code should I write to get the desired result.

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