Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15521

Loop through all CSV files in a folder

$
0
0

I'm trying to loop through only the csv files in a folder that contains many kinds of files and many folders, I just want it to list all of the .csv files in this folder.

Here's what I mean:

import os, syspath = "path/to/dir"dirs = os.listdir(path)for file in dirs:    if file == '*.csv':        print file

I know there is no wildcard variable in python, but is there a way of doing this?


Viewing all articles
Browse latest Browse all 15521

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>