[cx-oracle-users] How to handle quotes of columns in CSV file
Brought to you by:
atuining
From: Ivanelson N. <iva...@gm...> - 2013-01-03 22:45:09
|
Oracle is giving me the error ORA: 17022. I know a type error. I am reading a CSV with columns alpha and columns of value numeric. The method csv.reader is making all columns as alpha and do not know how to handle this in cx_Oracle, although I believe this is not a function of cx_Oracle. :( L = [] > > sql_insert = ('INSERT INTO {0}_TEMP (%s) VALUES (%s)'.format(vTable) % > > (','.join('%s' % name for name in vTables), > > ','.join(':{0}'.format(vIndex + 1) for vIndex in >> range(len(vTables))))) > > >> reader = csv.reader(open(infile), delimiter=';', quotechar='"') > > for row in reader: > > print row > > L.append(tuple(row)) > > >> cursor.prepare(sql_insert) > > cursor.executemany(sql_insert, L) > > My CSV: " 2102";"LINDOMAR MARTINS DE FREITAS";"RUA 02 > NR.270";"FORMOSA";"98130860";"TIMON";"MA";"ADMINISTRATIVO";"FATURISTA";"LINDOMAR";"S";20130103;20130103;20130103; > *100.00*;"TDC";"4";"88792334";"";"";"" My print row: > [' 2102', 'LINDOMAR MARTINS DE FREITAS', 'RUA 02 NR.270', 'FORMOSA', > '98130860', 'TIMON', 'MA', 'ADMINISTRATIVO', 'FATURISTA', 'LINDOMAR', 'S', > '20130103', '20130103', '20130103',* '100.00'*, 'TDC', '4', '88792334', > '', '', ''] Bad quotes :( Reference: http://www.dbaportal.eu/?q=node/143 []s Thanks |