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

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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