Clear Filters
Clear Filters

How to Read a file with unknown name

14 views (last 30 days)
naman on 24 Jan 2017
Commented: naman on 24 Jan 2017
I get one .csv file in a directory and I cannot control the name of it. Therefore, I want to read it without knowing its name. How can I do it ?

Accepted Answer

John Chilleri
John Chilleri on 24 Jan 2017
Edited: John Chilleri on 24 Jan 2017
You can do so like this (assuming only one csv file):
A = dir('*.csv');
B = csvread(;
Hope this helps!

More Answers (1)

Image Analyst
Image Analyst on 24 Jan 2017
Use dir('*.csv') to get a list of all csv files in that folder. See the FAQ:


Find more on Data Import and Analysis 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!