[Haskell-cafe] Re: How would you replace a field in a CSV file?

John Goerzen jgoerzen at complete.org
Mon Oct 9 23:12:38 EDT 2006


On 2006-10-01, Pete Kazmier <pete-expires-20060401 at kazmier.com> wrote:
> For those that know python, here is a very simple implementation that
> happens to be very fast compared to my Haskell version and very short:
>
>     for line in sys.stdin:
>         fields = line.split(',')

Of course, this doesn't handle quoted values that contain commas, which
are among the many joys* of parsing CSV files.

I might just point out the existance of MissingH.Str.CSV to you, which
can read and write CSV files.  See
http://gopher.quux.org:70/devel/missingh/html/MissingH-Str-CSV.html for
details.

A one-line call gives you a [[String]].

This uses Parsec, so it will not be a top-notch performer, but it is
elegant ;-)

* I mean "joy" sarcastically, in case it wasn't obvious.





More information about the Haskell-Cafe mailing list