0
How to store images path in csv file ?
I have a folders which contains images and want to stores all images path of different folders in csv file. Can anyone help me please?
3 ответов
+ 3
S.k. Gupta , have you done a try by yourself first? If not, please do so.
As a hint:
- import the python module >os< and from this use >walk<. With this you will be able to get all paths and filenames.
- To store these paths / filenames in a csv file you can use the python module >csv< to create the file.
Happy coding!
+ 2
S.k. Gupta , using listdir() returns everything that a directory contains:
- files
- directories
(I am not sure if you want to read through a storage device and get files from all subdirectories = directory tree? This is something else. in this case see sample in python docs :
https://docs.python.org/3.8/library/os.html?highlight=walk#os.walk )
If you want to get files and directory separated, you can use:
- walk from os module
An other possible way is to use module glob. It enables you to use wildcards to define file extensions.
0
Lothar , yes i tried by os.listdir() but this returned folders name and not gone in each folder and return image path.