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

169
Vistas
Count number of specific char appeared in a number of lines in csv file

I have those lines of data:

1234;06/07/22;06/07/22;VRT;  ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT;  ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT;  ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT;  ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT;  ;31070;some String content;some String content; ;147.10;A;1234

I want to count how much time the letter A appeared in those lines it sould print 5.

So what I have a file with 19 lines and all those lines has letter A when I tried this snipped of code it returns to me just 12. here is the image for demonstration: enter image description here

I tried this code:

let nLines = 0;
let counter = 0;

for (let i = 0, n = this.csvRecords.length; i < n; ++i) {
  if (this.csvRecords[i] === '\n' && this.csvRecords.length[i][10] === 'A') {
    ++nLines;
    counter++;
  }

  console.log("number of lines in the file is: ", this.csvRecords.length) // this is giving me 19 which is right
}

console.log(counter) // this is giving me 0 which is wrong

So console.log( "showing u[10] is: " , this.csvRecords[10].length); is printing me the 10th line and it counts data with deliminer and that's not what i want I want how much it appeared in all the lines.

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