def colarray=[]
def num
def newRole = rolecol.split(\',\')
def len = newRole.size()
def colarray = rolecol.tokenize(',').collect { "col$it" }.join(', ')
Then you will also need to escape your sql:
sql.eachRow("select col01, ${Sql.expand(colarray)} from read_csv where col01 = ? and ${Sql.expand('col' + usercol)} != ? ", [file.name,""])
the []
are there, because you are doing an implicit toString
on the list. use colarray.join(',')