Category: zipfile

Problem

Create zip archives programmatically.

Solution

  with zipfile.ZipFile("backup.zip", "w") as z:
    z.write("data.csv")
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path