Find all CSV files in a directory using Python

后端 未结 11 1732
生来不讨喜
生来不讨喜 2020-12-02 17:57

How can I find all files in directory with the extension .csv in python?

11条回答
  •  情深已故
    2020-12-02 18:53

    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:

    import os
    import glob
    
    os.chdir( '/path/to/main/dir' )
    result = glob.glob( '*/**.csv' )
    print( result )
    

提交回复
热议问题