I'm trying to upload a CSV file specified by the user in a form and
then parse it using DictReader.  Everything seems to be working until
I initialize DictReader with the uploaded file.  As soon as I try to
access any value in the row, it throws an odd exception.  Am I doing
something wrong or is the UploadedFile object incompatible with
DictReader?

if request.POST:
        form = ImportFileForm( request.POST, request.FILES )
        if form.is_valid():
                try
                        csvfile = request.FILES['filename'].read()     # reads 
entire file
                        reader = csv.DictReader( csvfile, 'r' )
                        for row in reader:
                                group_name = str.strip( row['Group Name'] )
                                                                #
throws exception "Group Name"
                except Exception, e:
                        print e
else:
        form = ImportFileForm()

return render_to_response('admin_import_from_excel.html', {'form':
form,}, RequestContext(request) )
Thanks in advance for any assistance.

Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to