
2 Jun
2006
2 Jun
'06
2:10 a.m.
dons:
briqueabraque:
Hi,
I need to edit big text files (5 to 500 Mb). But I just need to change one or two small lines, and save it. What is the best way to do that in Haskell, without creating copies of the whole files?
I'd think maybe a lazy bytestring would be ok.
Something like: import Data.ByteString.Lazy.Char8 B.putStr . B.unlines . B.map edit . B.lines =<< B.getContents
in the darcs version of Data.ByteString, here, http://www.cse.unsw.edu.au/~dons/fps.html Let me know how you go, it would make a good benchmark.
Oh, of course, if you actually don't want to copy the file, you'll need to strictly read the input file, in order to write over it safely. - Don