【发布时间】:2015-05-05 12:34:44
【问题描述】:
假设我的输入文件myInput.txt 如下所示:
~~~ text1
bla bla
some more text
~~~ text2
lorem ipsum
~~~ othertext
the wikipedia
entry is not
up to date
即有~~~分隔的文档。期望的输出如下:
text1: bla bla some more text
text2: lorem ipsum
othertext: the wikipedia entry is not up to date
我该怎么做?以下似乎很不自然,而且我失去了标题:
val converter: Task[Unit] =
io.linesR("myInput.txt")
.split(line => line.startsWith("~~~"))
.intersperse(Vector("\nNew document: "))
.map(vec => vec.mkString(" "))
.pipe(text.utf8Encode)
.to(io.fileChunkW("flawedOutput.txt"))
.run
converter.run
【问题讨论】:
-
@TravisBrown 看起来很有趣
标签: scala scalaz-stream