Created
October 7, 2013 19:00
-
-
Save haakonn/6873104 to your computer and use it in GitHub Desktop.
Just a quick Scala script to convert a certain logfile into CSV. Instead of instinctively going to bash or python for these things, why not Scala? Just run with 'scala makecsv.scala', starts and finishes quickly. No build step or bytecode or support files, just a script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
println("date,msisdn,message") | |
scala.io.Source.fromFile("problem.log").getLines().foreach { line => | |
val m = "^(.{19}).*msisdn='(.{10}).*msg='(.*)', status.*".r.findFirstMatchIn(line).get | |
println(s"""${m.group(1)},${m.group(2)},"${m.group(3)}"""") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment