Hello all, As I have been trying to improve my J skills I've been trying to incorporate it into my daily work, but I keep hitting a wall with my ability to dig in to "tables" (i.e., read in a CSV and then explore the data).
I've seen Dan Bron mention perhaps putting together a wiki page about this, but I thought maybe I could start the ball rolling here and maybe we could put something together... together. I'm using the baseball archive database as sample data since anyone can get at it (2012 CSV data, it's an 8MB zip and I'm looking at Master.csv): http://www.seanlahman.com/baseball-archive/statistics/ I run off the rails pretty quickly. If I could get this type of stuff done then I could double my usage of J day to day which would be a big help in learning more. Here's my poor attempt: load 'tables/csv' t=. readcsv '/home/dan/Downloads/Master.csv' NB. Let's see how many players are named Joe? NB. Hmm... first I need to know what the headers are hdr=.0{t NB. Ok. I want rows where nameGiven NB. is Joe (I won't worry about nicknames for NB. example purposes). NB. I can get a column like this: (<a:; 1) { t NB. So if I can figure out the index of NB. nameGiven in hdr then I can select that NB. column, then do the same thing to get the "Joe's" NB. Index of? 'nameGiven' i. hdr NB. Nope, doesn't work. Looks like it treats NB. each letter as an item (I guess this is because NB. the shape of hdr is not e.g., rows x columns anymore) NB. I could of course try the inverted table thing: ifa =: <@(>"1)@|: it=. ifa t NB. Well, now my header row is split among the columns, NB. Ok let's just count with our fingers and try: 'Joe' i. 16 { it NB. 3 NB. ok. I'm confused enough to stop now. Anyway, any help would be appreciated. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
