Skip to content

Instantly share code, notes, and snippets.

@luthfianto
Created September 2, 2019 14:35
Show Gist options
  • Save luthfianto/4b94eb63ff2acdf931d3afc43ec8376a to your computer and use it in GitHub Desktop.
Save luthfianto/4b94eb63ff2acdf931d3afc43ec8376a to your computer and use it in GitHub Desktop.
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