Re: Can't get Uploaded File into DictReader

2010-02-27 Thread jeff
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

Re: Can't get Uploaded File into DictReader

2010-02-11 Thread bruno desthuilliers
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

Re: Can't get Uploaded File into DictReader

2010-02-11 Thread bruno desthuilliers
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()

Re: Can't get Uploaded File into DictReader

2010-02-11 Thread Bill Freeman
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

Can't get Uploaded File into DictReader

2010-02-09 Thread jeff
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