Guest User

quick and filthy

a guest
Feb 6th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.03 KB | None | 0 0
  1. fileIn = new FileInputStream("data/config.csv")
  2. fileOut = new PrintStream("output/seb.csv")
  3.  
  4. lst = []
  5. while(true) {
  6.     buf = fileIn.read()
  7.     if(buf == -1) {
  8.         break
  9.     } else {
  10.         lst.add((char)buf)
  11.     }
  12. }
  13.  
  14. strBuf = ""
  15. lst.each { strBuf += it }
  16. lines = strBuf.split("\n")
  17. lst = []
  18. lst.add(["","CA913426        ","20111207.2","REALKREDIT DANMARK A/S 7% OBL. 1996/2029-10-01 SER.23", "DDK0009258022","VPDKDKKK","VPD","BANKRUPTCY","\"NOTIFICATION, COMP\"","NEWM","VOLU","2012-01-20","2012-01-20","2012-01-20","2012-01-20","2012-01-20","2012-01-20 12:00:00","2012-01-20","12:30","2012-01-20","2012-01-20 - 2012-01-21","2012-01-20 - 2012-01-21","2012-01-20 - 2012-01-21","1000","100","500","250","10.45","1000","2.45","EUR","IE1234567891","Inter Sec","New Sec","IE1234567892","CA000012","CASH"])
  19.  
  20. lines.each { lst.add(it.split(",")) }
  21.  
  22. for(i in 1..lst.size()-1) {
  23.     strBuf = ""
  24.     for(j in 1..lst[i].size()-1) {
  25.         if(lst[i][j] == "x") {         
  26.             lst[i][j] = lst[0][j]
  27.         }
  28.         strBuf += lst[i][j] + ","
  29.  
  30.     }
  31.     fileOut.write(strBuf[0..-2] + "\n")
  32. }
Advertisement
Add Comment
Please, Sign In to add comment