I have the following external method which takes an input .csv file and enters the data into a database by calling a ZSQL method. There may be errors in the input file and so I am trying to catch them and insert each bad row in a different table. The errors are detected by table constraints on the table definition and should be reported by the Psycopg connector. However no correct rows are entered and only the last error row is entered. Can anyone see what I am doing wrong in this script?
def timetabler(self,REQUEST): import csv,string f=REQUEST.form["TTEXPORT.CSV"] from cStringIO import StringIO filebody=StringIO(f.read()) r = csv.DictReader(filebody("day","periodstart","periodend" ,"year","teachgroup","teacher" ,"subject" ,"set" ,"room")) for row in r: try: self.insertintoiclasses(**row) except: self.insertimporterrors(**row) dtmlMethodName="manage_import_from_timetabler" return self[dtmlMethodName](self,self.REQUEST) regards garry _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )