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

2007-06-17 Thread Pete Kazmier
"Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> writes:

> On Jun 15, 2007, at 18:37 , Jason Dagit wrote:
>
>> I love to see people using Haskell, especially professionally, but I
>> have to wonder if the real tool for this job is sed? :-)
>
> Actually, while sed could do that, it'd be a nightmare.  You really
> want a parser to deal with general CSV like this, and while you can
> write parsers in sed, you *really* don't want to.  :)

sed ':a /,$/!{N;s/\n//;ba}' somefile.csv

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2007-06-17 Thread Brandon S. Allbery KF8NH


On Jun 17, 2007, at 14:04 , Pete Kazmier wrote:


"Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> writes:


On Jun 15, 2007, at 18:37 , Jason Dagit wrote:


I love to see people using Haskell, especially professionally, but I
have to wonder if the real tool for this job is sed? :-)


Actually, while sed could do that, it'd be a nightmare.  You really
want a parser to deal with general CSV like this, and while you can
write parsers in sed, you *really* don't want to.  :)


sed ':a /,$/!{N;s/\n//;ba}' somefile.csv


If it's simple enough, sure.  If you get into dealing with quoting,  
it gets a lot more complex in a hurry.


Of course, given that this is from Oracle, it *probably* doesn't.   
(But as a sysadmin and ex-dba, "probably" is worrisome)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe