예제 #1
0
def handle_uploaded_file(request, file):
    if not request.user.is_authenticated or not request.user.is_active:
        return redirect("/auth/")

    document = pandas.read_csv(file)

    if "Title" not in document or "Category ID" not in document or "Subcategory ID" not in document:
        return "error"
    book_names = document["Title"]
    category_names = document["Category ID"]
    subcategory_names = document["Subcategory ID"]

    for book_name, category_name, subcategory_name in zip(book_names, category_names, subcategory_names):
        book = Book(book_name=book_name, category_name=category_name, subcategory_name=subcategory_name)
        book.save()

    return "success"
    train_dataset_from_user_upload()
예제 #2
0
def add_predictions(request) :
	print "i was here"
	if not ( request.user.is_authenticated() or request.user.is_active == True):
		return redirect("/auth/")

	if request.method == 'POST' :
		print "here"
		predictions_list = json.loads(request.POST.get('predictions'))
		print predictions_list
		for prediction in predictions_list :
			#print prediction
			p = Prediction.objects.get(id = prediction)
			#print p.category_name
			print p
			p.is_added = "1"
			p.save()
			book = Book(book_name = p.book_name , category_name = p.category_name, subcategory_name = p.subcategory_name)
			book.save()
			
		train_dataset_from_predictions()
		return HttpResponse("done")