Project

General

Profile

« Previous | Next » 

Revision 4634

join: When a join mapping exists but is empty, still include any additional columns from that mapping in the combined row

View differences:

bin/join
79 79
                    if sep == '': break
80 80
                    suffix = sep+new_suffix+suffix # prepend new suffix
81 81
            
82
            is_empty = len(out_rows) == 1 and out_rows[0][1] == ''
83
            if is_empty: set_error('No non-empty join mapping for '+out_orig)
84
            
82 85
            # Write new mapping
83
            is_empty = len(out_rows) == 1 and out_rows[0][1] == ''
84 86
            if only_one and len(out_rows) > 1: # multiple outputs are ambiguous
85 87
                set_error('Ambiguous mapping for '+row[1]) # discards mapping
86
            elif out_rows and not is_empty: # found non-empty mapping(s)
88
            elif out_rows: # found mapping(s)
87 89
                for out_row in out_rows:
88 90
                    row_ = row[:] # don't modify row, since it will be reused
89 91
                    row_ = maps.merge_mappings(row_, out_row)
90 92
                    if row_[1] != '': row_[1] += suffix # don't modify out_row!
91 93
                    writer.writerow(row_)
92 94
                row_written = True
93
            else:
94
                msg = 'No'
95
                if is_empty: msg += ' non-empty'
96
                msg += ' join mapping for '+out_orig
97
                set_error(msg)
95
            else: set_error('No join mapping for '+out_orig)
98 96
        elif row[2] == '': # also no comment explaining why no input mapping
99 97
            set_error('No input mapping for '+row[0])
100 98
        

Also available in: Unified diff