'Unzipping the zipfiles within a url zipfile python
I can unzip a url zip file of csvs using the below code:
import requests
from zipfile import ZipFile
from io import BytesIO
import pandas as pd
z = 'www.someurl.zip'
r = requests.get(z)
getnames = ZipFile(BytesIO(r.content))
names = getnames.namelist()
for name in names:
df = pd.read_csv(getfiles.open(name), header=None, on_bad_lines='skip')
print(df)
But doing the same approach to unzip a url zipfile of zipfiles doesn't seem to work as there is no URL path
z = 'www.someurl.zip'
r = requests.get(z)
getnames = ZipFile(BytesIO(r.content))
names = getnames.namelist()
for name in names:
r = requests.get(name)
getfiles = ZipFile(BytesIO(r.content))
files = getfiles.namelist()
for file in files:
df = pd.read_csv(getfiles.open(file), header=None, on_bad_lines='skip')
print(df)
Is this possible without a url of the nested Zip file? And can you do this on the nth iteration?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|