Project

General

Profile

« Previous | Next » 

Revision 5591

sql_io.py: import_csv(): Take a reader and header rather than a stream to allow callers to pass in a wrapped CSV reader for filtering, etc.

View differences:

sql_io.py
256 256
    try: db.db.cursor().copy_expert(copy_from, stream)
257 257
    except Exception, e: sql.parse_exception(db, e, recover=True)
258 258

  
259
def import_csv(db, table, stream):
259
def import_csv(db, table, reader, header):
260 260
    def log(msg, level=1): db.log_debug(msg, level)
261 261
    
262 262
    # Get format info
263
    reader, header = csvs.reader_and_header(stream)
264 263
    col_names = map(strings.to_unicode, header)
265 264
    for i, col in enumerate(col_names): # replace empty column names
266 265
        if col == '': col_names[i] = 'column_'+str(i)

Also available in: Unified diff