Order of files pulled from Datastore
Show older comments
I have created a datastore with around 1000 csv files, labeled filename_1, filename_2,...filename_1000. When I try and read the data from the datastore into a new table though, it reads in a weird order:

How can I get it to read the files in the typical 1,2,3,etc order?
Here is the rest of the code for reference:

Thanks! Austin
1 Comment
Accepted Answer
More Answers (1)
"...around 1000 csv files, labeled filename_1, filename_2,...filename_1000"
It's sorted in ASCII order; hence filenames beginning with 0 come first, then numbers beginning with 1, etc., .... You should have used
N=1000;
fnames=compose('filename_%04d.csv',0:N).';
fnames([1:5 end-4:end])
Categories
Find more on Datastore in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!