You can download this code by clicking the button below.
This code is now available for download.
Compresses a file into a tar.gz archive.
Technology Stack : tarfile
Code Type : File compression
Code Difficulty : Intermediate
import array
import bisect
import cmath
import collections
import contextlib
import copy
import csv
import datetime
import enum
import functools
import html
import heapq
import io
import itertools
import json
import math
import os
import random
import re
import shutil
import smtplib
import statistics
import subprocess
import sys
import tarfile
import threading
import time
import uuid
def zip_file(file_path, output_path):
with tarfile.open(output_path, "w:gz") as tar:
tar.add(file_path, arcname=os.path.basename(file_path))