How do I read a large CSV file with Scala Stream class?

后端 未结 3 1226
野的像风
野的像风 2020-12-01 05:02

How do I read a large CSV file (> 1 Gb) with a Scala Stream? Do you have a code example? Or would you use a different way to read a large CSV file without loading it into me

3条回答
  •  北海茫月
    2020-12-01 05:32

    I hope you don't mean Scala's collection.immutable.Stream with Stream. This is not what you want. Stream is lazy, but does memoization.

    I don't know what you plan to do, but just reading the file line-by-line should work very well without using high amounts of memory.

    getLines should evaluate lazily and should not crash (as long as your file does not have more than 2³² lines, afaik). If it does, ask on #scala or file a bug ticket (or do both).

提交回复
热议问题