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