Created
September 2, 2019 14:35
-
-
Save luthfianto/4b94eb63ff2acdf931d3afc43ec8376a 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
import urllib | |
import asyncio | |
loop = asyncio.get_event_loop() | |
import pandas as pd | |
df=pd.read_csv("ktp-npwp-o.csv"); df.head() | |
async def aaa(row): | |
filename=row.image_url.split("/")[-1] | |
folder_name= row.image_type.lower() | |
try: | |
urllib.request.urlretrieve(row.image_url, f"./document-classifier/{folder_name}/{filename}") | |
except Exception as e: | |
print(e) | |
print(row.image_url, folder_name, filename) | |
async def main(): | |
print("main") | |
for row in df.itertuples(): | |
acoro = aaa(row) | |
loop.create_task(acoro) | |
loop.run_until_complete(main()) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment