You can download this code by clicking the button below.
This code is now available for download.
This function compresses a file at a specified path into a zip format and saves it to a specified output path.
Technology Stack : zipfile
Code Type : File processing
Code Difficulty : Intermediate
def zip_file(file_path, output_path):
import zipfile
with zipfile.ZipFile(output_path, 'w') as zipf:
zipf.write(file_path, arcname=file_path.split('/')[-1])
return f'Zip file created at {output_path}'