From mboxrd@z Thu Jan 1 00:00:00 1970 From: "charles snyder" Subject: Applying a user-defined function to cols in table Date: Fri, 12 Sep 2008 20:49:23 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0965955336==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KeKGN-0000er-0R for emacs-orgmode@gnu.org; Fri, 12 Sep 2008 21:49:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KeKGL-0000cg-Jh for emacs-orgmode@gnu.org; Fri, 12 Sep 2008 21:49:26 -0400 Received: from [199.232.76.173] (port=39123 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KeKGL-0000cd-GI for emacs-orgmode@gnu.org; Fri, 12 Sep 2008 21:49:25 -0400 Received: from rv-out-0708.google.com ([209.85.198.240]:54014) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KeKGL-0002DC-5z for emacs-orgmode@gnu.org; Fri, 12 Sep 2008 21:49:25 -0400 Received: by rv-out-0708.google.com with SMTP id k29so1181513rvb.6 for ; Fri, 12 Sep 2008 18:49:23 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --===============0965955336== Content-Type: multipart/alternative; boundary="----=_Part_51720_20075441.1221270563091" ------=_Part_51720_20075441.1221270563091 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi I am trying to apply a function to one column in a table and output the result to another column. The function looks like this: (defun yahoo (stock_symbol) (let (url contents fields price-string price) (setf url "http://finance.yahoo.com/d/quotes.csv?s=") (str+! url stock_symbol) (str+! url "&f=sl1d1t1c1ohgv&e=.csv") (setf contents (http-get url)) (setf fields (split-sequence #\, contents)) (setf price-string (second fields)) (setf price (read-from-string price-string)) price)) This table looks like this: | ! | stockname | symbol | shares | curr_price | | 1 | apple | aapl | 800 | | | 2 | google | goog | 2100 | | #+TBLFM: $5= yahoo $3 (I'm using org 6.06b, gnu emacs 22.2 on a mac.) I have tried some other variants without success. Is this even possible? Thanks! -- Charles L. Snyder, MD Professor of Surgery www.clsnyder.com ------=_Part_51720_20075441.1221270563091 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi

I am trying to apply a function to one column in a table and output the result to another column. The function looks like this:

(defun yahoo (stock_symbol)
   (let (url contents fields price-string price)
     (setf url "http://finance.yahoo.com/d/quotes.csv?s=")
     (str+! url stock_symbol)
     (str+! url "&f=sl1d1t1c1ohgv&e=.csv")
     (setf contents (http-get url))
     (setf fields (split-sequence #\, contents))
     (setf price-string (second fields))
     (setf price (read-from-string price-string))
     price))


This table looks like this:

|  !   | stockname | symbol | shares | curr_price |
|  1  |      apple     | aapl   |    800 |            |
|  2  |    google       | goog  |   2100 |         |
#+TBLFM: $5= yahoo $3

(I'm using org 6.06b, gnu emacs 22.2 on a mac.)


I have tried some other variants without success.
Is this even possible?

Thanks!

--
Charles L. Snyder, MD
Professor of Surgery
www.clsnyder.com
------=_Part_51720_20075441.1221270563091-- --===============0965955336== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0965955336==--