the httpget.ijs on the web is empty.
I downloaded httpget.2.ijs and renamed it and it worked.

] z=: currencytable httpget URL
smoutput z
smoutput'pund'
smoutput ] 'GBP' exrate z
smoutput'rúbla'
smoutput ] 'RUB' exrate z
smoutput'dollar'
smoutput ] 'USD' exrate z
smoutput'sænsk króna'
smoutput ] 'SEK' exrate z

worked fine by calling run script


2010/5/7 Ian Clark <[email protected]>:
> Here's my take on a currency conversion table from Björn's URL.
> It uses Oleg's httpget.ijs to snatch data from the European Central
> Bank website.
> --BTW: the website in question has a seriously annoying robot face in
> the top right corner. :-)
>
> NB. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> NB. Source of exchange rate data...
> URL=: 'http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html'
>
> require 'strings'               NB. for: rplc
> load '~user/httpget.ijs'        NB. 
> http://www.jsoftware.com/jwiki/Scripts/HTTP%20Get
>
> detag=: monad define            NB. strip out html tags
> z=: -. +/\(y='<')-(y='>')
> (z#y)-.'>'
> )
>
> deLF=: #~ (+. (1: |. (> </\)))@(LF&~:)  NB. c/f deb with LF not ' '
> u2b=: [: <;._1 LF , ]                   NB. (LF-sep)-->boxed
> threes=: 3 : '((<.3%~$y),3)$y'          NB. reshape: 3-cols
>
> currencytable=: monad define
>  NB. extracts currency table from html source str: y
> z=. (('<tbody>' E. z)i. 1) }. z=.y
> z=. (('</tbody>' E. z)i. 1) {. z
> z=. (deLF detag z)-.TAB
> z=. z rplc '&nbsp;' ; '' ; (LF,' ') ; ''
> z=. threes }. u2b z
> )
>
> exrate=: dyad define
>  NB. the euro rate-of-exchange for a given currency
>  NB. x is currency code, eg 'USD' or 'GBP'
>  NB. y is table as returned by: currencytable
> z=. (0{"1 y)-.each ' '  NB. table key col (deblanked)
> z=. z i. <x             NB. find first instance of x
> _".>(<z,2){y            NB. return corresp numeral in col 2
> )
>
> ] z=: currencytable httpget URL
> ] 'GBP' exrate z
>
> NB. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Fn: currencytable gives a table like this:
>
> ┌────┬───────────────────────┬─────────┐
> │USD │US dollar              │1.2727   │
> ├────┼───────────────────────┼─────────┤
> │JPY │Japanese yen           │119.34   │
> ├────┼───────────────────────┼─────────┤
> │BGN │Bulgarian lev          │1.9558   │
> ...
>
> Who can see how to improve on my code?
>
> Ian
>
>
> On Fri, May 7, 2010 at 4:14 AM, Ian Clark <[email protected]> wrote:
>> Thanks Björn.
>>
>> European Central Bank... why didn't I think of that?
>>
>> The format of the html looks nice'n'easy. I'll have fun writing a
>> utility to snatch the figures from it (Needed for TABULA).
>>
>> Ian
>>
>>
>> 2010/5/7 Björn Helgason <[email protected]>:
>>> http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html
>>>
>>> 2010/5/7 Ian Clark <[email protected]>:
>>>> Does anyone do on-line currency conversion in J?
>>>>
>>>> Can somebody recommend a web-page where I can download conversion
>>>> factors for major currencies (without subscribing to a service)? Daily
>>>> updates will do.
>>>>
>>>> I'd use www.xe.com, but the tabular format is a bit cumbersome (though
>>>> not unmanageable). Surely simpler formats like csv are available?
>>>>
>>>> Ian
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>
>>>
>>>
>>> --
>>> Björn Helgason, Verkfræðingur
>>> Fornustekkum II
>>> 781 Hornafirði,
>>> t-póst: [email protected]
>>> gsm: +3546985532
>>> sími: +3544781286
>>> http://groups.google.com/group/J-Programming
>>>
>>>
>>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>>
>>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>>>          /|_      .-----------------------------------.
>>>         ,'  .\  /  | Með léttri lund verður        |
>>>     ,--'    _,'   | Dagurinn í dag                     |
>>>    /       /       | Enn betri en gærdagurinn  |
>>>   (   -.  |        `-----------------------------------'
>>>   |     ) |         (\_ _/)
>>>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>>>   `. )----'        (")_(") ☃☠
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði,
t-póst: [email protected]
gsm: +3546985532
sími: +3544781286
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
          /|_      .-----------------------------------.
         ,'  .\  /  | Með léttri lund verður        |
     ,--'    _,'   | Dagurinn í dag                     |
    /       /       | Enn betri en gærdagurinn  |
   (   -.  |        `-----------------------------------'
   |     ) |         (\_ _/)
  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
   `. )----'        (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to