Skip to content

Instantly share code, notes, and snippets.

@ponsea
Created January 18, 2018 13:13
Show Gist options
  • Save ponsea/ded7f687397430f3f9d04329d7f4513c to your computer and use it in GitHub Desktop.
Save ponsea/ded7f687397430f3f9d04329d7f4513c to your computer and use it in GitHub Desktop.
val file = Source.fromFile(args(0), "utf-8")
val lines = file.getLines
val dateTimeSep = """- (\d\d\d\d)年(\d\d)月(\d\d)日 .曜日 (\d\d:\d\d)""".r
val articles = mutable.TreeMap[String, String]()
var nowDate = "";
for (line <- lines) {
line match {
case dateTimeSep(year, month, day, time) =>
nowDate = s"$year-$month-$day $time"
case _ =>
if (articles contains nowDate) {
articles(nowDate) += line + "\n"
} else {
articles += (nowDate -> (line + "\n"))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment