def _build_entry(parts, existing_list_d, key_value, key_field_num,<EOL>key_is_field_number, header=None,<EOL>output_type=OutputType.error_on_dups,<EOL>ignore_missing_keys=False, keep_key_col=False):
if key_value.strip() == "<STR_LIT>":<EOL><INDENT>if ignore_missing_keys:<EOL><INDENT>return<EOL><DEDENT>raise MissingKeyError("<STR_LIT>")<EOL><DEDENT>if key_value in existing_list_d:<EOL><INDENT>if output_type is OutputType.error_on_dups:<EOL><INDENT>raise DuplicateKeyError(key_value + "<STR_LIT>")<EOL><DEDENT>elif (output_type is OutputType.all_pairwise_combinations or<EOL>output_type is OutputType.column_wise_join):<EOL><INDENT>pass  <EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>existing_list_d[key_value] = []<EOL><DEDENT>if key_is_field_number:<EOL><INDENT>ne = [parts[i] for i in range(<NUM_LIT:0>, len(parts))<EOL>if i != key_field_num or keep_key_col]<EOL>existing_list_d[key_value].append(ne)<EOL><DEDENT>else:<EOL><INDENT>ne = {}<EOL>for i in range(<NUM_LIT:0>, len(parts)):<EOL><INDENT>if i == key_field_num and not keep_key_col:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>ne[header[i]] = parts[i]<EOL><DEDENT><DEDENT>existing_list_d[key_value].append(ne)<EOL><DEDENT>
Build and add an entry to existing_list_d.

If the key is a field number, the entry added will be a list of lists. The
inner list contains one item per column. and the outer list allows more than
one entry to be stored per key (but if allow_duplicates is false, an
exception will be raised if more than one needs to be stored).

:param parts:               the (already tokenized) list of column entries.
:param existing_list_d:     a dictionary indexed by key value containing the
                            the already processed entries. The new entry will
                            be added to this using <key_value> as a key
:param key_value:           the key value to use to add the new entry to
                            <existing_list_d>
:param key_field_num:       which column is the key_value from (number,
                            indexed from 0)
:param key_is_field_number: True if the <key_value> is actually the column
                            index, rather than a column name
:param header:              list giving the names of the columns. Can be None
                            if columns have no names (no header)
:param dup_method:          ...
:param ignore_missing_keys: ...