Changeset 12812


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

Skip empty rows produced by spreadsheet software.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_customer_data.csv

    r12537 r12812  
    33Y777777,Claus,Finau,2,1990-01-03,bb@aa.ng,1234,m,requested
    44,Susann,Berson,3,1990-01-04,cc@aa.ng,1234,F,requested
     5,,,,,,,,
     6,, ,,,  ,,,
     7,,,<IGNORE>,, ,,,
    58,Else,Mueller,4,1990-01-05,dd@aa.ng,1234,f,approved
    69X888888,Alfons,Meier,5,1990-01-02,ee@aa.ng,1234,m,requested
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12633 r12812  
    259259        self.assertEqual(num_warns,0)
    260260        self.assertEqual(len(self.app['customers']), 10)
     261        # Three empty rows have been skipped.
     262        self.assertEqual(num, 12)
    261263        self.assertEqual(self.app['customers']['X666666'].reg_number,'1')
    262264        self.assertEqual(
  • 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.