Created
January 18, 2018 13:13
-
-
Save ponsea/ded7f687397430f3f9d04329d7f4513c to your computer and use it in GitHub Desktop.
This file contains 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
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