Trying to parse CSV file in Grails -
i'm trying parse csv file has 3 fields.
my method looks this:
// action called when user submits upload form def handle() { commonsmultipartfile file = request.getfile('filecsv') if(file.empty) { flash.error = g.message(code:'',default:'empty cannot uploaded') } else { inputstream fs = file.inputstream fs.spliteachline(',') { row -> new connection( randomizedid: row[0], token1: row[1], token2: row[2] ).save(flush: true) key++ println("connection added") } } }
looking @ output, line "connection added" printed multiple times. when go looking @ connection list, there none...
Comments
Post a Comment