Last active
          December 2, 2019 10:42 
        
      - 
      
 - 
        
Save MattHealy/bd971b5fff4664ee062d8c4686dcecc3 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or 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
    
  
  
    
  | #!/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