I may be biased, but I would say that you are on the right track!
It looks like you want people to be able to download csv, then your web application will process it and give the results? If so, check out the Django docs:
https://docs.djangoproject.com/en/1.3/topics/http/file-uploads/
Nothing complicated if you create a Django Form object with a FileField as per the example.
from django import forms class UploadFileForm(forms.Form): file = forms.FileField()
You will then post it on your web page or template, including the correct enctype :
<form enctype="multipart/form-data" method="post" action="/foo/"> {{form.as_p}} </form>
Finally, you are dealing with this in your view, which processes the message (with the URL from the form action):
def handle_csv_upload(request): form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): results = do_my_csv_magic(request.FILES['file'])
In addition, PythonAnywhere does not require much configuration. The file is saved (temporarily) in / tmp, which will work fine. If you want to save the file for later, you will have to add code for this.
Hope this helps. We are here if you have more questions!
hwjp
source share