Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda