[PYTHON] Unzip the internet zip file

Unzip the zip file on the internet

Meteorological Agency [List of regional meteorological stations [ZIP compression format]](https://www.jma. go.jp/jma/kishou/know/amedas/ame_master.zip) is used. The contents of the zip file is only ʻame_master.csv`

python


import requests
import zipfile
import io
import pandas as pd

url = 'https://www.jma.go.jp/jma/kishou/know/amedas/ame_master.zip'
csv_name = 'ame_master.csv'
zip_res = requests.get(url)

with zipfile.ZipFile(io.BytesIO(zip_res.content)) as zip_f:
    csv_data = zip_f.read(csv_name)
    df = pd.read_csv(io.BytesIO(csv_data), encoding='cp932')

Recommended Posts

Unzip the internet zip file
Have pandas read the zip file on the web
Unzip all zip files under the current directory
Zip, unzip with python
Unzip a ZIP file larger than 4GB on Linux.
Download the file in Python
File access under the directory
Can you delete the file?
Extract the xz file with python
Recursively unzip zip files with python
Save the binary file in Python
Simply view the Jupyter notebook file
Download the file deployed with appcfg.py
The story of the "hole" in the file
Extract the targz file using python
Sakura Use Python on the Internet
Open the file with the default app
Get the address from the zip code
Split the pyramid framework ini file
Get the file path using Pathlib
[Unzip] How to decompress only arbitrary files from those whose directory delimiter in the zip file is backslash