Skip to content

Instantly share code, notes, and snippets.

@MattHealy
Last active December 2, 2019 10:42
Show Gist options
  • Save MattHealy/bd971b5fff4664ee062d8c4686dcecc3 to your computer and use it in GitHub Desktop.
Save MattHealy/bd971b5fff4664ee062d8c4686dcecc3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
import zipfile
import os
dirs = next(os.walk('.'))[1]
for d in dirs:
print("Preparing {} ZIP archive".format(d))
zipfilename = d + ".zip"
path = "./" + d
csvfiles = sorted(
list(filter(lambda x: x.endswith('.csv'), os.listdir(path))))
with zipfile.ZipFile(os.path.join(path, zipfilename), 'w',
zipfile.ZIP_DEFLATED) as myzip:
for csvfile in csvfiles:
if '-NOTES' not in csvfile:
print("Zipping {}".format(csvfile))
myzip.write(os.path.join(path, csvfile), csvfile)
myzip.close()
for csvfile in csvfiles:
os.remove(os.path.join(path, csvfile))
print("Zip: {}".format(os.path.join(path, zipfilename)))
subprocess.run(
["aws", "s3", "sync",
"./", "s3://client-import-data/", "--exclude", "zipem.py"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment