Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib
- import csv
- from threading import Thread
- def download_function(lower_limit,upper_limit):
- counter = 0
- file_object = open("../train.csv")
- csv_obj = csv.reader(file_object)
- for row in csv_obj:
- counter+= 1
- print counter
- if counter <= lower_limit:
- continue
- else:
- try:
- urllib.urlretrieve(row[0],str(counter)+"-"+row[1]+"-.JPG")
- except:
- download_function(counter,counter)
- if counter > upper_limit:
- break
- for j in range(31,101):
- print j
- Thread(target=download_function,args=(j*1000,(j)*1000+300)).start()
- Thread(target=download_function,args=(j*1000+300,(j)*1000+400)).start()
- Thread(target=download_function,args=(j*1000+400,(j)*1000+500)).start()
- Thread(target=download_function,args=(j*1000+500,(j)*1000+800)).start()
- Thread(target=download_function,args=(j*1000+800,(j+1)*1000)).start()
Add Comment
Please, Sign In to add comment