我有一個CSV文件,其中一個是許多CSV文件。這樣的事情:使用Scala將文本文件解析爲組
"First Part"
"Some", "data", "in", "here"
"More", "stuff", "over", "here"
"Another Part"
"This", "section", "is", "not", "the", "same", "as", "the", "first"
"blah", "blah", "blah", "blah", "blah", "blah", "blah", "blah", "blah"
"Yet another section"
"And", "this", "is", "yet", "another"
"blah", "blah", "blah", "blah", "blah"
我想分解成單獨的組件。鑑於我知道每個部分的標題,如果我可以做某種類型的groupBy
或者其中我傳遞了一組代表標題模式的正則表達式並返回Seq[Seq[String]]
或類似內容,那就會很好。
可能有很多因素需要考慮。你需要處理大文件還是可以將所有內容加載到內存中?你需要處理轉義的CSV字符嗎?你關心表現還是你需要一些簡單的東西? – huynhjl 2013-03-09 17:54:27
這是一個小文件......最大100K,所以我打算把所有東西都放到記憶裏 – andyczerwonka 2013-03-09 20:46:08