Last active
May 10, 2021 17:50
-
-
Save RackReaver/dd69c5b91b514fa109de134cf91277b8 to your computer and use it in GitHub Desktop.
crowdstrike:script: falcon data replicator unzipper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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