Project

General

Profile

« Previous | Next » 

Revision 8069

csvs.py: InputRewriter.readline(): Surround function in a try block that prints all exceptions, so that debugging information is available if an error occurs when this stream is used as input for psycopg's copy_expert() (COPY FROM)

View differences:

csvs.py
4 4
import _csv
5 5
import StringIO
6 6

  
7
import exc
7 8
import streams
8 9
import strings
9 10
import util
......
192 193
        self.dialect = dialect
193 194
    
194 195
    def readline(self):
195
        row = self.reader.readline()
196
        if row == '': return row # EOF
197
        
198
        line_stream = StringIO.StringIO()
199
        csv.writer(line_stream, self.dialect).writerow(row)
200
        return line_stream.getvalue()
196
        try:
197
            row = self.reader.readline()
198
            if row == '': return row # EOF
199
            
200
            line_stream = StringIO.StringIO()
201
            csv.writer(line_stream, self.dialect).writerow(row)
202
            return line_stream.getvalue()
203
        except Exception, e:
204
            exc.print_ex(e)
205
            raise
201 206
    
202 207
    def read(self, n): return self.readline() # forward all reads to readline()

Also available in: Unified diff