[Zope] csv import continued
Jim Washington
jwashin at vt.edu
Sun Aug 8 12:37:03 EDT 2004
garry saddington wrote:
> Now i have an iterable file for the csv module in this code:
>
> def students(self,REQUEST):
> import csv
> f=REQUEST.form["students.csv"]
> from cStringIO import StringIO
> filebody=StringIO(f.read())
> reader = csv.DictReader(filebody,("firsname","surname",
> "year","form","gender"))
> for row in reader:
> self.writestudents(row)
>
> Writestudents is a zsql method with the following body:
>
> insert into students (firstname,surname,year,form,gender)
> values(<dtml-sqlvar firstname type="string">,
> <dtml-sqlvar surname type="string">,
> <dtml-sqlvar year type="int">,
> <dtml-sqlvar form type="string">,
> <dtml-sqlvar gender type="string">)
>
> Now when i test this combination i get a missing input variable error:
>
> Missing input variable, firstname
>
> Can anyone see what I am missing?
>
If you copied-and-pasted the code, you have "firsname" instead of
"firstname" in the "reader" line of "students".
I would look at that first.
--Jim Washington
More information about the Zope
mailing list