Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion How would you replace a field in a CSV file?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bulat Ziganshin  
View profile  
 More options Oct 2 2006, 6:02 am
Newsgroups: fa.haskell
From: Bulat Ziganshin <bulat.zigans...@gmail.com>
Date: Mon, 02 Oct 2006 10:02:24 UTC
Local: Mon, Oct 2 2006 6:02 am
Subject: Re: [Haskell-cafe] How would you replace a field in a CSV file?
Hello tpledger,

Monday, October 2, 2006, 3:11:29 AM, you wrote:

> For such a small self-contained task, I don't think Haskell
> is any better than Python.

i disagree. while it's hard to beat Python version in number of lines,
Haskell version may have the same length and better performance.

for this particular task, using list as intermediate datastructure
make program both long and inefficient. if ByteString will include
array-based splitting and joining, the things will become much better

main = B.interact $ B.unlines . map doline . B.lines
    where doline    = B.joinArray comma . mapElem 9 fixup . B.splitArray ','
          fixup s   = M.findWithDefault s s
          comma     = B.pack ","

mapElem n func arr = arr//[(n,func (arr!n))]

if mapElem, splitArray, joinArray will be library functions (i think
they are good candidates) this program will be not longer than Python
one

--
Best regards,
 Bulat                            mailto:Bulat.Zigans...@gmail.com

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.