khalido
9/25/2017 - 1:24 AM

[download multiple files using python] and save to data dir

[download multiple files using python] and save to data dir

exprs__url = "https://github.com/cs109/2014_data/raw/master/exprs_GSE5859.csv"
sampleinfo_url = "https://github.com/cs109/2014_data/raw/master/sampleinfo_GSE5859.csv"

urls = [exprs__url, sampleinfo_url]
filenames = ["exprs_GSE5859.csv", "sampleinfo_GSE5859.csv"]

for url, filename in zip(urls, filenames):
    r = requests.get(url, stream=True)
    with open("data/"+filename, 'wb') as fd:
        for chunk in r.iter_content(chunk_size=256):
            fd.write(chunk)
    print(f"file {filename} downloaded succesfully")