When the user uploads a file, I want it to store the file, read the first 10 rows and send the first 10 rows back to the page. I'm not sure how to go about doing this in the views or on the client side.
def UploadTest(request):
if request.POST and request.FILES:
csvfile = request.FILES['csv_file']
dialect = csv.Sniffer().sniff(codecs.EncodedFile(csvfile, "utf-8").read(1024))
csvfile.open()
reader = csv.reader(codecs.EncodedFile(csvfile, "utf-8"), delimiter=',', dialect=dialect)
return render(request, 'index.html', {"form": reader} )
That is what I have in my views.py
right now. But I don't want it to render a new page.