I'm just an animal looking for a home

Ice Weasels statistics


Thanks in large part to the efforts of Justin and David, we have been keeping batting/pitching/fielding statistics for the Ice Weasels for almost a year now.  Of course, that meant that they needed to be displayed on our web page.  Because I knew it wouldn’t take me long to implement, I wrote a Korn shell script to do this on my Linux box at home.  It just read in all of the game data (which is stored as comma-separated data in plain text files), did some calculations, and generated the desired HTML output.

This worked fine, but the approach had a few drawbacks.  First, it takes an unreasonably long time to run.  At first it wasn’t an issue, but as the amount of game data increased, it was starting to be problematic.  I’d find myself waiting on it to complete so I could finish updating the web page.  I’m sure I could have worked on streamlining the Korn shell, but I always knew that I’d eventually need to re-write it in a “real” programming language to realize substantial performance benefits.

The second drawback is that the script didn’t give me all of the output that I wanted.  I had gotten in the habit of posting the top 5 leaders in various statistical categories, but since I came up with this idea after I had written the script, it wasn’t done for me.  So after I’d run the script, I’d need to manually figure out the leaders.  Not a big task, but something that could easily be automated.  I was reluctant to add it to the script, though, since I knew I’d be re-writing it in another language anyway.

The final drawback was that as we collected more data, there became a lot of interesting ways it could be presented.  The script just sums up all of the data you give it, and spits out a table of the overall statistics.  I’d run the script on ALL of the game data files, and then only on the ones from 2011, and then only on the ones for a given season, etc.  In that fashion I would generate several different web pages.  But I had to group together the desired data files and run the script for each web page I wanted.  And it couldn’t do things like show me, on one page, a season-by-season listing of a given player’s stats (kind of like you’d find on the back of a baseball card).

For some reason on Saturday morning, over coffee, I started to work on this.  Jen left around noon, and I spent the rest of the day working on it, until around midnight or so.  And then I spent a couple more hours on Sunday evening on it.  I chose to do it in Java because I’ve had the most recent experience with it, and because it allows me to focus on the program logic without having to worry about pointer errors, etc.  Anyway, I’ve gotten a framework in place which reads in all of the game data files, and then allows you to parse it in various ways.  So at this point I just need to think of all of the different ways I’d like to see the data presented, and then code that up.  But the time-consuming part — loading all of the data and figuring out how I wanted to structure it — is already done.

This sort of thing is classic Mitch behavior.  I had been putting this off for months.  Every time I ran the old script I’d be frustrated at how long it took, and I’d promise myself that I’d re-write it that week.  But I never did.  I’m terrible about getting started on things, but once I do, I get very absorbed by them.

Anyway, I know this is very fascinating to all of you!  For any of you reading who visit the Ice Weasels web page, you can look for some enhancements in the near future.  None of this stuff has gone live yet, but it will soon.


Author: mitcharf

vegan, curmudgeon, animal lover, feminist, agnostic, cat whisperer, bookworm, hermit, Red Sox fan, Cthulhu enthusiast, softball player, man-about-town

Leave a Reply

Required fields are marked *.

Notify me of followup comments via e-mail. You can also subscribe without commenting.