Ignore:
Timestamp:
23 Mar 2015, 11:32:12 (10 years ago)
Author:
Henrik Bettermann
Message:

Skip empty rows produced by spreadsheet software.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/batching.py

    r12334 r12812  
    274274        return errs, inv_errs, conv_dict
    275275
     276    def emptyRow(self, row):
     277        """Detect empty rows.
     278        """
     279        for value in row.values():
     280            if value.strip() and not value in (None, IGNORE_MARKER):
     281                return False
     282        return True
     283
    276284    def doImport(self, path, headerfields, mode='create', user='Unknown',
    277285                 logger=None, ignore_empty=True):
     
    308316        for raw_row in reader:
    309317            num += 1
     318            # Skip row if empty
     319            if self.emptyRow(raw_row):
     320                continue
    310321            string_row = self.applyMapping(raw_row, mapping)
    311322            if ignore_empty and mode in ('update',):
Note: See TracChangeset for help on using the changeset viewer.