It works for me in interactive interpreter:
Another possibility is slash direction, if you are on microsoft, could be an issue.
and the is_file() qualifier will only return normal files as defined in https://docs.python.org/3/library/pathlib.html
try eliminating the condition and see if you get results
>>> from pathlib import Path >>> mydir = Path('/media/.../data/json') >>> filelist = [filename for filename in mydir.iterdir() if filename.is_file()] >>> print(len(filelist)) 2 >>> for filename in filelist: ... print(filename.name) ... walmart.json walmart_1.jsonas before, I replaced part of the path with ellipsis (for display only).
Another possibility is slash direction, if you are on microsoft, could be an issue.
and the is_file() qualifier will only return normal files as defined in https://docs.python.org/3/library/pathlib.html
try eliminating the condition and see if you get results
filelist = [filename for filename in mydir.iterdir()]