I've made a code that reads files from the folder and saves their paths.
sample_directory = []sample_files = []for (dirpath, dirnames, filenames) in walk('./Samples'): sample_files.extend(filenames) breakpaths = [] for i in range(len(sample_files)): path = os.path.realpath(sample_files[i]) paths.append(path)sample_directory.append(sample_files)sample_directory.append(paths)print(sample_directory)
[['smpl1.xlsx', 'smpl2.xlsx', 'smpl3.xlsx', 'smpl4.xlsx', 'smpl5.xlsx'], ['/Users/Graygood/Desktop/Science comput/Application/smpl1.xlsx', '/Users/Graygood/Desktop/Science comput/Application/smpl2.xlsx', '/Users/Graygood/Desktop/Science comput/Application/smpl3.xlsx', '/Users/Graygood/Desktop/Science comput/Application/smpl4.xlsx', '/Users/Graygood/Desktop/Science comput/Application/smpl5.xlsx']]
The problem is that it skips one folder and the true path is:
/Users/Graygood/Desktop/Science comput/Application/Samples/smpl1.xlsx
Why is that and how to fix it?