savezip#

savezip(filename=None, files=None, data=None, folder=None, sanitizepath=True, basename=False, tobytes=True, verbose=True, **kwargs)[source]#

Create a zip file from the supplied list of files (or less commonly, supplied data)

Parameters:
  • filename (str/path) – the name of the zip file to write to

  • files (list) – file(s) and/or folder(s) to compress

  • data (dict) – if supplied, write this data as well or instead (must be a dictionary of filename keys and data values)

  • folder (str) – optional additional folder for the filename

  • sanitizepath (bool) – whether to sanitize the path prior to saving

  • basename (bool) – whether to use only the file’s basename as the name inside the zip file (otherwise, store folder info)

  • tobytes (bool) – if data is provided, convert it automatically to bytes (otherwise, up to the user)

  • verbose (bool) – whether to print progress

  • kwargs (dict) – passed to sc.save()

Examples:

scripts = sc.getfilelist('./code/*.py')
sc.savezip('scripts.zip', scripts)

sc.savezip('mydata.zip', data=dict(var1='test', var2=np.random.rand(3)))
New in version 2.0.0: saving data
New in version 3.0.0: “tobytes” argument and kwargs; “filelist” renamed “files”