Working with ZIP files
As was mentioned previously, CSV files are very common for sharing data. Because they are plain text files, they can get big. One solution for managing the size of CSV files is to compress them. In this recipe, we will look at loading files from ZIP files.
We will load a CSV file that is compressed as the only thing in the ZIP file. This is the behavior that you get if you were to right-click on a file in the Finder on Mac and click Compress beatles.csv. We will also look at reading a CSV file from a ZIP file with multiple files in it.
The first file is from the fueleconomy.gov website. It is a list of all car makes that have been available in the US market from 1984-2018.
The second file is a survey of users of the Kaggle website. It was intended to get information about the users, their background, and the tools that they prefer.
How to do it...
- If the CSV file is the only file in the ZIP file, you can just call the
read_csv
function...