'Extracting .zip in python using extractall
I'm trying to save the log folder in the data folder, extract the compressed files in the log folder, and code them to save them in each folder
But i can't get rid of the compression I think i'm reading the route correctly. . .
import os
import glob
import zipfile
import sys
try:
args = sys.argv
curdir = os.path.dirname(args[0])
for directory in glob.glob(curdir + '/data/*/'):
for path in glob.glob(directory + '*/*_SmmLogs.zip'):
output_path = os.path.dirname(directory)
if os.path.exists(output_path):
continue
print('Extract')
with zipfile.ZipFile(path) as zfile:
zfile.extractall(os.path.dirname(path))
print('processing Chuck rep of ' + directory)
print('reading smmlogs')
except:
import traceback
traceback.print_exc()
# input('error')
Terminal is processing Chuck rep of d:/Coding/zip haedong/data\20201104025058633\ reading smmlogs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
