Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/groovy
- import com.csvreader.*
- import groovy.sql.Sql
- def sql = Sql.newInstance("jdbc:mysql://localhost:3306/is3nwp", "", "", "com.mysql.jdbc.Driver")
- def getPhoneName = { id ->
- def row = sql.firstRow("select vendor, model from ppdb2_profiles where id=${id}")
- if(row == null) {
- println "id not found - ${id}"
- }
- return "${row.vendor} ${row.model}"
- }
- def readValues = { String file ->
- def reader = new CsvReader(file,';' as char)
- def map = new HashMap<String, String>()
- while (reader.readRecord()) {
- String[] values = reader.values
- map.put(values[0], values[1])
- }
- return map
- }
- def phones = readValues('profileId_Qty.csv')
- phones.each {
- def phone = getPhoneName(it.key)
- println "${phone};${it.value}"
- }
Add Comment
Please, Sign In to add comment