Ignore:
Timestamp:
18 Jul 2012, 14:16:21 (12 years ago)
Author:
Henrik Bettermann
Message:

Avoid that script has to be run twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/tools/fix_import_file.py

    r9009 r9019  
    184184    """Replace input fieldnames by fieldnames of COLNAME_MAPPING.
    185185    """
    186     header = dict([(name, name) for name in fieldnames])
    187186    # Remove whitespaces
    188     for key in header:
    189         header[key] = key.strip()
     187    header = dict([(name, name.strip()) for name in fieldnames])
    190188    for in_name, out_name in COLNAME_MAPPING.items():
    191         if in_name not in header:
     189        if in_name not in header.values():
    192190            continue
    193         header[in_name] = out_name
     191        # Inverse dictionary lookup
     192        key = [key for key,value in header.items() if value==in_name][0]
     193        header[key] = out_name
    194194    return header
    195195
Note: See TracChangeset for help on using the changeset viewer.