I am trying to remove all lines of data for whom the "last order date" (row 17 of my CSV file) is after 8/31/2019. My code was weeding out some, but there were a few later dates left behind. I switched all the date values to Serial Date Numbers in hopes that would simplify the process, but it's still not weeding out anything after 7183 (the serial date number for 8/31/19). I am out of ideas and would greatly appreciate any feedback.
Code:
segment = readtable('myFile.csv');a = 1;rows = height(segment); newDate = [];for f = 1:rows addDate = datenum(segment{f, 17}); newDate(f) = addDate; endcutoffDateOG = datetime('08/31/0019','InputFormat','MM/dd/uuuu', 'Format', 'preserveinput');cutoffDate = datenum(cutoffDateOG);while a < rows if newDate(a)>cutoffDate || isnat(segment{a,17}) == 1 segment(a,:) = []; rows = rows-1; end a = a+1;endend
Best Answer