Skip to content

Instantly share code, notes, and snippets.

@RackReaver
Last active May 10, 2021 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RackReaver/dd69c5b91b514fa109de134cf91277b8 to your computer and use it in GitHub Desktop.
Save RackReaver/dd69c5b91b514fa109de134cf91277b8 to your computer and use it in GitHub Desktop.
crowdstrike:script: falcon data replicator unzipper
# PYTHON 2.7
def unzip_data(src, dest):
"""Unzips *.gz file and places it in new location following the same directory structure.
args:
src (str): *.gz file to be unzipped
dest (str): drop location for unzipped file
return: None
"""
filename = os.path.basename(src)[:-3]
directory = os.path.dirname(src).split('/')[-1]
os.mkdir(dest + directory)
with gzip.open(src, 'rb') as s_file, \
open(dest + directory + '/' + filename, 'wb') as d_file:
shutil.copyfileobj(s_file, d_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment