Project

General

Profile

« Previous | Next » 

Revision 1134

bin/map: Fixed bug in previous implementation of allowing maps for CSV inputs to contain entries for columns that are not in the CSV file

View differences:

bin/map
190 190
            reader = csv.reader(sys.stdin)
191 191
            cols = reader.next()
192 192
            col_idxs = dict([(value, idx) for idx, value in enumerate(cols)])
193
            
194
            mappings_new = []
193 195
            for i, mapping in enumerate(mappings):
194 196
                in_, out = mapping
195 197
                if metadata_value(in_) == None:
196
                    try: mappings[i] = (col_idxs[in_], out)
197
                    except KeyError: pass
198
                    try: mapping = (col_idxs[in_], out)
199
                    except KeyError: continue
200
                mappings_new.append(mapping)
201
            mappings = mappings_new
198 202
            
199 203
            def get_value(in_, row):
200
                try: value = row[in_]
201
                except KeyError: pass
204
                value = row[in_]
202 205
                if value != '': return value
203 206
                else: return None
204 207
            row_ct = map_rows(get_value, reader)

Also available in: Unified diff