Success with the named queries, thanks to Kathy for the suggestion and to the guy that invented copy and paste!
Bit wordy, but it works
import os
import csv
path = 'c:\\temp\\new haff\\work\\'
filename = "00397943.txt"
file = open(path + filename, 'r')
i = 0
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8]}
nam_q = "dwh_9"
for line in file.readlines():
data = line.split(",")
#l_l = line_length
l_l = len(data)
print "This row has: " + str(l_l) + "columns"
i = i + 1
if l_l == 10:
print "insert string is: insert into 10, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9]}
nam_q = "dwh_10"
elif l_l == 11:
print "insert string is: insert into 11, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10]}
nam_q = "dwh_11"
elif l_l == 12:
print "insert string is: insert into 12, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11]}
nam_q = "dwh_12"
elif l_l == 13:
print "insert string is: insert into 13, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12]}
nam_q = "dwh_13"
elif l_l == 14:
print "insert string is: insert into 14, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13]}
nam_q = "dwh_14"
elif l_l == 15:
print "insert string is: insert into 15, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13], "macro_6":data[14]}
nam_q = "dwh_15"
elif l_l == 16:
print "insert string is: insert into 16, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13], "macro_6":data[14], "macro_7":data[15]}
nam_q = "dwh_16"
elif l_l == 17:
print "insert string is: insert into 17, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13], "macro_6":data[14], "macro_7":data[15], "macro_8":data[16]}
nam_q = "dwh_17"
elif l_l == 18:
print "insert string is: insert into 18, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13], "macro_6":data[14], "macro_7":data[15], "macro_8":data[16], "macro_9":data[17]}
nam_q = "dwh_18"
elif l_l == 19:
print "insert string is: insert into 19, etc"
params = {"filename":filename, "order_num":data[0], "piece_id":data[1], "constant":data[2], "description":data[3], "bin_id":data[4],
"profile_code":data[5], "colour_code":data[6], "length":data[7], "end_cut":data[8], "macro_1":data[9], "macro_2":data[10], "macro_3":data[11],
"macro_4":data[12], "macro_5":data[13], "macro_6":data[14], "macro_7":data[15], "macro_8":data[16], "macro_9":data[17], "macro_10":data[18]}
nam_q = "dwh_19"
system.db.runNamedQuery(nam_q, params)
print "Db insert complete"
print "Batch count (i): " + str(i)