Assuming you don't know which rows of the text file correspond to your start and end timestamps, what you want cannot be achieved just ith readtable. There's no way to tell readtable to stop once a specific value has been encountered (even using detectImportOptions). The only way to tell readtable to stop at a specific line is with the DataLines property and you have to know in advance at which line to stop.
You could determine that line by parsing the file yourself line by line with textscan for example but then there'd be no point in using readtable after that.
Unless the file is significantly larger than your range of interest, it's simpler to just read the whole file and then use isbetween to keep the required range. Otherwise, as said, you'll have to use textscan to parse the file line by line until you encounter your end timestamp. It's significantly more work than readtable, you lose automatic format detection, nice table formating, etc. and because you'll be reading the file line by line may actually be slower than reading the whole file in one go. It would go like this:
fmt = '%D%...';
data = {}
fid = fopen(yourfile, 'rt', 'n', yourfileencoding);
while ~feof(fid)
line = textscan(fid, fmt, 1);
if line{1} > endtimestamp
break;
end
if line{1} >= starttimestamp
data = [data; line];
end
end
fclose(fid);
Best Answer