Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!