[Haskell-cafe] How to cut a file effciently?

Johan Tibell johan.tibell at gmail.com
Wed Apr 8 01:52:34 EDT 2009


On Wed, Apr 8, 2009 at 7:20 AM, Magicloud Magiclouds
<magicloud.magiclouds at gmail.com> wrote:
> Hi,
>  Let us say I have a text file of a million lines, and I want to cut
> it into smaller (10K lines) ones.
>  How to do this? I have tried a few ways, none I think is lazy (I
> mean not reading the file all at the start).

I would just seek to the approximate chunk boundaries (10k, 20k, etc)
and the read forward until hitting a newline.

Cheers,

Johan


More information about the Haskell-Cafe mailing list