I have an Excel file WK6 that is downloaded in the below folder:
C:UserskjScriptsShResultWk6
The Python script should first navigate till the above directory and then find the excel file WK6 (the name of the excel file changes as per week) and compress it. Then move it to some other directory.
Please help me understand how can I find and compress the file in python?
Advertisement
Answer
for zipping the file you can use following:
from zipfile import ZipFile import os path = r'C:UserskjScriptsShResultWk6' os.chdir(path) ZipFile('<new path>/name.zip', 'w').write('Wk6.csv')