How do i sort csv file in righ order??
Show older comments
I have csv folder that contain 1-20 csv file like 1.csv,2.csv...20.csv. How to sort all those files?? 1.csv 2.csv 3.csv ... 20.csv But in MATLAB i got the files in a different way. like 1.csv 10.csv 11.csv what is the solution
3 Comments
Image Analyst
on 21 Sep 2018
What was your edit? Whatever it was, your current question does not change my answer below.
shubh
on 21 Sep 2018
"what is the solution": download my FEX submission natsortfiles:
Answers (2)
Image Analyst
on 21 Sep 2018
0 votes
Of course the best solution is to just create the files with the proper filename to begin with, like 01.csv, 2.csv, etc.
But if you can't (like you're not the person creating the files), see this link: https://blogs.mathworks.com/pick/2014/12/05/natural-order-sorting/
dpb
on 21 Sep 2018
A) Don't name them that way..use
>> num2str([1:3].','%03d.csv')
ans =
3×7 char array
'001.csv'
'002.csv'
'003.csv'
>>
Categories
Find more on Shifting and Sorting Matrices 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!