简体   繁体   中英

os.listdir() in python doesn't show all the files of directory. It skipped few of them

I tried to open all the files(csv) of a directory and append a column to new dataframe. But, os.listdir() doesn't show all files of the directory.. skipped few of them

import os
path1=r'D:\data files'
filenames=os.listdir(path1)
print(filenames)

You could try doing it with system commands

files = os.system("cd /data\ files && ls")

You might have to add in the path of the directory but this should to the trick. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM