Baseball on a Stick: Ordinal Out of Range Errors (Parsing Errors, Fun with Unicode)

If you use Baseball on a Stick for your PITCHf/x database purposes, you may have run into an annoying ordinal out of range error. If you dive into it, you’ll notice that the instigator is the ‘cc’ field, which contains the description of the stupid “nasty factor.”

This field has unicode characters, and despite my best efforts to convert the DB and set character sets to take utf-8 in MySQL and python, I kept getting the errors. I finally said screw it, I’m just purging that field. I never look at it. And I’ll save a few bytes, too.

Anyway,  edit the bbos\src\bbos\gameday\parser\ file with these modifications:

[python]atbatID = tag.parentNode.getAttribute(‘num’)
pitch[‘gameAtBatID’] = atbatID
pitchTime = tag.getAttribute(‘sv_id’)
ccTag = tag.getAttribute(‘cc’)

if ccTag:
pitch[‘cc’] = ""

if pitchTime:
pitch[‘sv_id’] = self.__getPitchTime__(pitchTime)[/python]

The ccTag portions are my additions to just strip that field. The rest is there for context.


Leave a Reply

Your email address will not be published. Required fields are marked *