'only files names in .7z using python
I am reading .7z file and want to extract only files name with extension. I want abc.txt only. right now I am doing split with "\" and getting last right of (\) and then checking (.) in it and it is not full proof. Is there any better way using python? or If I have a string how can I check if this is a valid file in OS without using OS library.
7z gives hierarchical path for folder.
parent folder
parent folder\child folder
parent folder \child folder\abc.txt
with py7zr.SevenZipFile(folder_location, 'r') as archive:
file_paths_reports = archive.getnames()
for file_rep in file_paths_reports:
print(file_rep)
# how can I check if this is a file in a folder?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
