'Wipe out any existing table definition keywords from the header.
If specified, only clear keywords for the given table index (shifting
up keywords for any other columns).  The index is zero-based.
Otherwise keywords for all columns.'

def _clear_table_keywords(self, index=None):

    table_keywords = []
    for (idx, keyword) in enumerate(self._header.keys()):
        match = TDEF_RE.match(keyword)
        try:
            base_keyword = match.group('label')
        except Exception:
            continue
        if (base_keyword in KEYWORD_TO_ATTRIBUTE):
            num = (int(match.group('num')) - 1)
            table_keywords.append((idx, match.group(0), base_keyword, num))
    rev_sorted_idx_0 = sorted(table_keywords, key=operator.itemgetter(0), reverse=True)
    for (idx, keyword, _, num) in rev_sorted_idx_0:
        if ((index is None) or (index == num)):
            del self._header[idx]
    if (index is not None):
        sorted_idx_3 = sorted(table_keywords, key=operator.itemgetter(3))
        for (_, keyword, base_keyword, num) in sorted_idx_3:
            if (num <= index):
                continue
            old_card = self._header.cards[keyword]
            new_card = ((base_keyword + str(num)), old_card.value, old_card.comment)
            self._header.insert(keyword, new_card)
            del self._header[keyword]
        if ('TFIELDS' in self._header):
            self._header['TFIELDS'] -= 1
