def getcolumnindex(sf, name):
    """Get the index of a shapefile's column by name."""
    for i in range(len(sf.fields)):
        if sf.fields[i][0] == name:
            return (i - 1)
    raise Exception("Column not found: " + name)