I have a list of URLs to download data. I am doing this on Kaggle. I want to know how to download this data, save to kaggle or local machine. The goal is, download this data onto Python and combine them into a single CSV file and download this big file. Presently each URL corresponds to one year data.
Ref: Download Returned Zip file from URL
My code:
url_list = ['https://mapfiles.nrel.gov/data/solar/ae014839fbbe9de5c30bedf56a2f5521.zip', 'https://mapfiles.nrel.gov/data/solar/ea8f39523778ba0223a28116a3e9d85a.zip']
import requests, zipfile, io
data_list = []
for url in url_list:
r = requests.get(url)
z = zipfile.ZipFile(io.BytesIO(r.content))
data_list.append(pd.read_csv(z.open(z.namelist()[0])))
# Create a big dataframe
df = pd.concat(data_list)
df.to_csv('WeatherData.csv')
It is working as I intended. But, is there a better way of doing it.