How can I find all files in directory with the extension .csv in python?
相关问题
- Flush single app django 1.9
- Upload file to Google Cloud Storage using AngularJ
- How to stop a dbus gobject loop
- Python's difflib SequenceMatcher speed up
- Getting 'Missing required field: member' w
相关文章
- Is there a size limit for HTTP response headers on
- Does there exist empty class in python?
- ImportError: No module named twisted.persisted.sty
- Get a header with Python and convert in JSON (requ
- File Upload of more than 4GB
- The current request is not a multipart request - S
- python unit testing methods inside of classes
- Input file in laravel 5.2?
I had to get
csv
files that were in subdirectories, therefore, using the response from tchlpr I modified it to work best for my use case:The function
find_csv_filenames()
returns a list of filenames as strings, that reside in the directorypath_to_dir
with the given suffix (by default, ".csv").Addendum
How to print the filenames:
use Python OS module to find csv file in a directory.
the simple example is here :
While solution given by thclpr works it scans only immediate files in the directory and not files in the sub directories if any. Although this is not the requirement but just in case someone wishes to scan sub directories too below is the code that uses os.walk
Copied from this blog.
This will help to identify path also of these csv files