regex is a good fit for the problem as well:

require 'web/gethttp'
require 'regex'
page=:gethttp '
http://www.jsoftware.com/jwiki/Community/Conference2014?action=raw'
sections=:(] rxcut~ 1{"2 '===\s(\w+)\s===' rxmatches ])
attendees=:(] {~ [: >: (<'Attendees') i.~ ])
countries=:(]rxfrom~ 1{"2 (('\s\*\s.*?,\s(\w+)',CR)) rxmatches ])@:>
({.;#)/.~ > countries attendees sections page

+-----------+--+
|USA        |20|
+-----------+--+
|Canada     |14|
+-----------+--+
|Germany    |1 |
+-----------+--+
|Denmark    |2 |
+-----------+--+
|UK         |2 |
+-----------+--+
|Switzerland|2 |
+-----------+--+
|Finland    |2 |
+-----------+--+



On Wed, Jul 2, 2014 at 3:35 AM, Lippu Esa <[email protected]> wrote:

> Thank you Dan and Raul!
>
> For me different is better because I always seem to get new insight in J
> and the problem at hand. Like in this case.
>
> Esa
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Dan Bron
> Sent: 1. heinäkuuta 2014 22:11
> To: [email protected]
> Subject: Re: [Jprogramming] Where do we come from?
>
> Better?
>
>            jConferenceAttendees     =:  tableFormatter @:
> attendeeCountrySummary
> @: attendeeCountries @: attendeeList @: attendeeSection
>              tableFormatter         =:  (,. TAB&,.)&>/ @: (<@:":@:,.@:>"1)
> @: |:
>              attendeeCountrySummary =:  (~. ((_,~]) \:~ ;"1 0 , 'TOTAL' ;
> +/@])
> #/.~)
>              attendeeCountries      =:  1 }. (}.~ 2+i:&',');._2
>              attendeeList           =:  (#~ _1 |. 1 = (2#LF) +/\@:E. ])
>              attendeeSection        =:  '=== Attendees ===' (] }.~ E. i.
> 1:) ]
>
>            jConferenceAttendees toJ gethttp
> 'http://www.jsoftware.com/jwiki/Community/Conference2014?action=raw'
>         TOTAL           44
>         USA             20
>         Canada          14
>         Hong Kong        2
>         Denmark          2
>         UK               2
>         Finland          2
>         Germany          1
>         Switzerland      1
>
> How about just sillier, instead?
>
>            jConferenceAttendees  f.
>         (,. (9{a.)&,.)&>/@:(<@:":@:,.@:>"1)@:|:@:(~. ((_ ,~ ]) \:~ ;"1 0 ,
> 'TOTAL'
> ; +/@]) #/.~)@:(1 }. (}.~ (2 + i:&','));._2)@:(#~ (_1 |. 1 = (10 10{a.)
> +/\@:E. ]))@:('=== Attendees ===' (] }.~ E. i. 1:) ])
>
> -Dan
>
> ----- Original Message ---------------
>
>
>
> Subject: [Jprogramming] Where do we come from?
>    From: Lippu Esa <[email protected]>
>    Date: Tue, 1 Jul 2014 16:21:14 +0000
>      To: "'Programming forum'" <[email protected]>
>
> Hello all!
>
> I was looking at the J Conference 2014 attendee list
> (//www.jsoftware.com/jwiki/Community/Conference2014) and was pleased to
> see that we are so many!
>
> Naturally I wanted to see the country distribution of the attendees. Being
> an eternal novice I'd like to see alternative (i.e. better :) ) solutions
> to this.
>
> sort (~.,.[:<"0[:+/"1=) }.@>@{: each ',' cut each 'b' freads
> 'h:/data/j/jconf2014'
>
> +--------------+
> ¦Canada     ¦14¦
> +-----------+--¦
> ¦Denmark    ¦2 ¦
> +-----------+--¦
> ¦Finland    ¦2 ¦
> +-----------+--¦
> ¦Germany    ¦1 ¦
> +-----------+--¦
> ¦Hong Kong  ¦2 ¦
> +-----------+--¦
> ¦Switzerland¦1 ¦
> +-----------+--¦
> ¦UK         ¦2 ¦
> +-----------+--¦
> ¦USA        ¦20¦
> +--------------+
>
> See you soon!
>
> Esa
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to