Skip to content

Instantly share code, notes, and snippets.

@khalido
Last active March 13, 2023 05:20
Show Gist options
  • Save khalido/a0621620387555ed92c8931c07bcb5e4 to your computer and use it in GitHub Desktop.
Save khalido/a0621620387555ed92c8931c07bcb5e4 to your computer and use it in GitHub Desktop.
[download multiple files using python] and save to data dir #file
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment