[Haskell-cafe] How to deal with huge text file?

Daniel Fischer daniel.is.fischer at web.de
Tue May 25 05:17:13 EDT 2010


On Tuesday 25 May 2010 10:44:57, Ivan Lazar Miljenovic wrote:
> Daniel Fischer <daniel.is.fischer at web.de> writes:
> > On Tuesday 25 May 2010 08:14:13, Ivan Miljenovic wrote:
> >> On 25 May 2010 16:12, Magicloud Magiclouds
> >>
> >> <magicloud.magiclouds at gmail.com> wrote:
> >> > Yes, this code works with a little hack. Thank you.
> >>
> >> I'm scared to ask: what pray tell is this little hack?
> >
> > Looking at it again, probably making it work at all, because I never
> > consumed the "Log for " lines, so produced an infinite list of empty
> > lists
> >
> > :-/
>
> Oh, yeah, I've done that before (with custom chunking functions, etc.).

Who hasn't?

>
> Just so you know, the split package might already have a function to do
> what you want...

Sort of. Not one function, but the building blocks:

import Data.List (isPrefixOf)
import Data.List.Split

msplit = split (keepDelimsL $ whenElt ("Log for " `isPrefixOf`))

I think. But who looks at API docs in the dead of the night when cooking up 
the function seems so easy :)


More information about the Haskell-Cafe mailing list