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

233
Visualizações
Read csv files with a random string in filename in javascript

I have CSV files that are named like the following

SN00275 Dutycycle_Testrun2 (2021-11-10 1055).csv
SN00275 Dutycycle_Testrun2 (2021-11-10 2201).csv
SN00275 Dutycycle_Testrun2 (2021-11-10 0908).csv
SN00275 Dutycycle_Testrun2 (2021-11-09 1451).csv
SN00275 Dutycycle_Testrun2 (2021-11-09 2201).csv
SN00275 Dutycycle_Testrun2 (2021-11-09 0612).csv
SN00275 Dutycycle_Testrun1 (2021-11-08 1125).csv
SN00275 Dutycycle_Testrun1 (2021-11-08 2201).csv
SN00275 Dutycycle_Testrun1 (2021-11-08 0908).csv
SN0000 Dutycycle_Testrun1 (2021-11-07 2359).csv

I want to plot a chart of the files based on the date (of the last 3 days). However, I do not want to plot the files with names that do not start with "SN00275".

I have the following code, I would like some help with the naming.

function makeRequest(filenames) {
  return $.get("Folder/SN00275"+"need_help_here"+fdate+ "and_need_help_here"+").csv", function(csvString) {
    var fileData = $.csv.toArrays(csvString, { onParseValue: $.csv.hooks.castToScalar });
    var removeRows = 1;
    while(removeRows--) {
      fileData.shift();
    }
  });
}

fdate is a variable with the dates. I decided to split the filename into 5 parts, but I would like some help with what goes on in those two parts.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to know all the files since there is no logic because there are random names. Then, just iterate them and check if they match a regex, for example

^(?!SN00275)SN\d+ (.+) \(2021-11-09 (\d+)\)\.csv$

It also returns 2 capture groups: the first is the random name; the second is the number after the date.

Of course you need to replace the date with fdate.

Check a test here: https://regex101.com/r/zPrreK/4

about 4 years ago · Juan Pablo Isaza Relatório
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