Want to get data with some missing values from cvs into postgresql. I am happy to insert using strings. I would like a fast was to do this using list or something similer. I also need to check for missing values and substitute as I get an error other wise.
for w in csvReader:
if a ==0:
var = w
sql_table = 'CREATE TABLE TableName (%s)' % ','.join('%s VARCHAR(50)' % name for name in var)
dict_cur.execute(sql_table)
else:
colnum = 0
for col in w:
nms= col
print w, 'column'
#this is not correct
sql_insert = ('INSERT INTO TableName (%s) VALUES (%s)' % (','.join('%s' % name for name in var),','.join('%s' % nm for nm in nms)))
cursor.execute(sql_insert)
colnum += 1
print w
a = a + 1
error Traceback (most recent call last): File "/home/matthew/workspace/dfdsggd/try_db_thing.py", line 41, in cursor.execute(sql_insert) psycopg2.ProgrammingError: syntax error at or near "." LINE 1: ...ORDER_ADM,MONTH_ADM,DAY_ADM,YEAR_ADM) VALUES (2,6,7,.,3,5,7) ^