Guest User

Untitled

a guest
Jul 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import urllib
  2. import csv
  3. from threading import Thread
  4.  
  5.  
  6. def download_function(lower_limit,upper_limit):
  7. counter = 0
  8. file_object = open("../train.csv")
  9. csv_obj = csv.reader(file_object)
  10. for row in csv_obj:
  11. counter+= 1
  12. print counter
  13. if counter <= lower_limit:
  14. continue
  15. else:
  16. try:
  17. urllib.urlretrieve(row[0],str(counter)+"-"+row[1]+"-.JPG")
  18. except:
  19. download_function(counter,counter)
  20. if counter > upper_limit:
  21. break
  22.  
  23. for j in range(31,101):
  24. print j
  25. Thread(target=download_function,args=(j*1000,(j)*1000+300)).start()
  26. Thread(target=download_function,args=(j*1000+300,(j)*1000+400)).start()
  27. Thread(target=download_function,args=(j*1000+400,(j)*1000+500)).start()
  28. Thread(target=download_function,args=(j*1000+500,(j)*1000+800)).start()
  29. Thread(target=download_function,args=(j*1000+800,(j+1)*1000)).start()
Add Comment
Please, Sign In to add comment