Thanks for the feedback. The bit about it being iterable put me on
the right track and it turned out to be pretty simple. For the
benefit of others, here's the basic code to select a CSV file on the
local machine and process it on the server using DictReader to manage
the columns:
FORM:
class I
On Feb 10, 2:50 am, jeff wrote:
> 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 exc
On Feb 11, 4:17 pm, Bill Freeman wrote:
>
> I suspect that DictReader process the file as an iterator of lines
Don't suspect, make sure:
http://docs.python.org/library/csv.html#csv.reader
"""
csvfile can be any object which supports the iterator protocol and
returns a string each time its next()
The DictReader constructor requires a file like object as it's first argument,
not a string. It is also not like open(), so it doesn't take the 'r' argument.
You could try:
...
reader = csv.DictReader(request.FILES['filename'])
...
but you may have to normalize the line endings.
I suspe
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
5 matches
Mail list logo