Hi Dan,

I similarly struggled when I first started and also use J to work with flat
files.

Here are some examples of different ways of working with the data:

load 'tables/csv'

t=. readcsv '/temp/Master.csv'

cols=. {.t                                               NB. head of t

data=. }. t                                              NB. behead t

colIdx=: cols i. ]                                     NB. i. finds the
first


names=. (colIdx <'nameFirst') {"1 data     NB. {"1 looks up by col index
(e.g. 16{"1 data)

joes=.((<'Joe') ([: I. =) names) { data        NB. [: I = finds all indices
and then grab the rows



]numjoes=. # joes

398


freq=:({.;#)/.~


nameFrequency=.freq names                   NB. Don't unbox names,
otherwise it pads to the longest and makes it difficult to search



   2{. nameFrequency

┌────────┬──┐

│┌────┐ │58│

││Hank│ │ │

│└────┘ │ │

├────────┼──┤

│┌──────┐│4 │

││Tommie││ │

│└──────┘│ │

└────────┴──┘




]uniqueNameCount=.# nameFrequency

2209


]joeCount=. ((>0{"1 nameFrequency) i. <'Joe') { nameFrequency NB. find Joe
in frequency table


┌─────┬───┐

│┌───┐│398│

││Joe││ │

│└───┘│ │

└─────┴───┘




On Mon, Oct 7, 2013 at 8:56 PM, Dan Bron <[email protected]> wrote:

> You mean " 'data' is plural " .
>
> -Dan
>
> PS: http://en.m.wikipedia.org/wiki/Muphry's_law
>
> (Yes, that link is spelled correctly :)
>
> Please excuse typos; composed on a handheld device.
>
> On Oct 7, 2013, at 8:00 PM, Eldon Eller <[email protected]> wrote:
>
> > Data are plural.
> >
> > On 10/07/2013 02:04 PM, Dan Bron wrote:
> >> Ganesh Rapolu
> >>>  Because the data is boxed, all comparisons must be boxed.
> >> This was very well put (one short sentence which both clarifies the
> problem
> >> and justifies the solution).
> >>
> >> -Dan
> >>
> >>
> >>
> >> ----------------------------------------------------------------------
> >> 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