Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mydb",
- "user", "pswd", "com.mysql.jdbc.Driver")
- def people = sql.dataSet("PERSON")
- new File("users.csv").splitEachLine(",") {fields ->
- people.add(
- first_name: fields[0],
- last_name: fields[1],
- email: fields[2]
- )
- }
- @Grab('com.xlson.groovycsv:groovycsv:0.2')
- import com.xlson.groovycsv.CsvParser
- def csv = '''Name,Lastname
- Mark,Andersson
- Pete,Hansen'''
- def data = new CsvParser().parse(csv)
- for(line in data) {
- println "$line.Name $line.Lastname"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement