[Haskell-cafe] Sneaking haskell in the workplace -- cleaning csv files

Sebastian Sylvan sebastian.sylvan at gmail.com
Fri Jun 15 20:34:02 EDT 2007


On 16/06/07, Jim Burton <jim at sdf-eu.org> wrote:
>
> Sebastian Sylvan wrote:
> >
> > A sorry, I thought the delimiter was a line delimiter. I'm trying to get
> to
> > that fusion goodness by using built-in functions as much as possible...
> >
> > How about this one:
> >
> > clean del = B.map ( B.filter (/='\n') ) . B.groupBy (\x y -> (x,y) /=
> > (del,'\n'))
> >
> > That groupBy will group it into groups which don't have the delimiter
> > followed by a newline in them (which is the sequence your rows end
> with),
> > then it filters out newlines in each row. You might want to filter out
> > spaces first (if there are any) so that you don't get a space between
> the
> > delimiter and newline at the end...
> >
> >
> I think you still need unlines after that so is the time complexity
> different to the
>
> unlines . foldr (function including `last') . lines
>
> in my first post? Or is it better for another reason, such as "fusion
> goodness"?
>


Benchmark it I guess :-)
Both versions use a non-bytestring recursive functions (the outer
B.mapshould just be a straight map, and yours use a foldr), which may
mess fusion
up... Not sure what would happe here...
I don't have a Haskell compiler at this computer so I can't try anything
out...


-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070616/27e11502/attachment.htm


More information about the Haskell-Cafe mailing list