Created
January 17, 2023 13:46
-
-
Save sayakpaul/cada598d8321a5f6cb8cc16fe736ae07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Referred from https://stackoverflow.com/questions/534839/how-to-create-a-guid-uuid-in-python | |
""" | |
import os | |
import uuid | |
from concurrent.futures import ThreadPoolExecutor | |
import pandas as pd | |
import requests | |
def download(url, path): | |
response = requests.get(url) | |
with open(path, "wb") as handle: | |
handle.write(response.content) | |
df = pd.read_csv("path_to_aesthetics_6plus_8k.csv") | |
urls = df["URL"].values.tolist() | |
paths = [] | |
for _ in urls: | |
hex = uuid.uuid4().hex | |
paths.append(f"{hex}.jpg") | |
with ThreadPoolExecutor(max_workers=8) as executor: | |
executor.map(download, urls, paths) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment