zipfile is a built-in Python module for organizing multiple files into one .zip archive, making files easier to back up, upload, and share. section 5.1.5
A typical archive task has three parts:
- Prepare several CSV files, such as nfl_offensive_stats.csv, actors.csv, and chores.csv. section 5.1.5
- Create my_stuff.zip, add each file, and close the archive. section 5.1.5
- Use related functions to read or extract archived files when needed. section 5.1.5
Create an archive
import zipfile zf = zipfile.ZipFile('my_stuff.zip', 'w', zipfile.ZIP_DEFLATED) zf.write('nfl_offensive_stats.csv') zf.write('actors.csv') zf.write('chores.csv') zf.close() This creates one compressed archive containing the three CSV files. section 5.1.5
Table 5.2 Summary of commonly used Python modules
|
Module
|
Built-In
|
Description
|
|---|---|---|
|
csv
|
Yes
|
Aids in the reading, writing, and analysis of CSV files
|
|
zipfile
|
Yes
|
Aids in the creation and extraction of compressed zip archive files
|
|
matplotlib
|
No
|
Graphics library for plotting that serves as the basis of other graphics libraries and can offer high levels of customization
|
|
plotly
|
No
|
A graphics library used for creating interactive plots for the web
|
|
seaborn
|
No
|
A graphics library built on top of matplotlib that aids in creating high- quality plots more easily than matplotlib
|
|
pandas
|
No
|
A data processing library that specializes in data frames, which are analogous to spreadsheets
|
|
scikit-learn
|
No
|
Contains basic tools for machine learning (i.e., helping to learn from data and make predictions)
|
|
numpy
|
No
|
Offers highly efficient data processing
|
|
pygame
|
No
|
A game programming library that helps to build interactive, graphical games in Python
|
|
django
|
No
|
Web development library that aids in designing websites and web applications
|
Compare zipfile with other commonly used Python modules and see that it is built in, unlike several data and graphics libraries. section 5.1.5
