Changeset 6824 for main/waeup.sirp/trunk/src/waeup/sirp/utils
- Timestamp:
- 28 Sep 2011, 17:08:05 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py
r6276 r6824 102 102 def applyMapping(self, row, mapping): 103 103 """Apply mapping to a row of CSV data. 104 104 105 """ 105 106 result = dict() 106 107 for key, replacement in mapping.items(): 108 if replacement == u'--IGNORE--': 109 # Skip ignored columns in failed and finished data files. 110 continue 107 111 result[replacement] = row[key] 108 112 return result 109 113 110 114 def getMapping(self, path, headerfields, mode): 111 """Get a mapping from CSV file headerfields to actually used 112 fieldnames. 115 """Get a mapping from CSV file headerfields to actually used fieldnames. 116 113 117 """ 114 118 result = dict() … … 117 121 for num, field in enumerate(headerfields): 118 122 if field not in self.location_fields and mode == 'remove': 119 # Ignore non-location fields when removing... 120 field = '--IGNORE--' 123 # Skip non-location fields when removing. 124 continue 125 if field == u'--IGNORE--': 126 # Skip ignored columns in failed and finished data files. 127 continue 121 128 result[raw_header[num]] = field 122 129 return result … … 250 257 conv_warnings = self.stringFromErrs(errs, inv_errs) 251 258 self.writeFailedRow( 252 failed_writer, raw_row, conv_warnings)259 failed_writer, string_row, conv_warnings) 253 260 continue 254 261 row.update(conv_dict) … … 258 265 num_warns += 1 259 266 self.writeFailedRow( 260 failed_writer, raw_row,267 failed_writer, string_row, 261 268 "Not all parents do exist yet. Skipping") 262 269 continue … … 264 271 num_warns += 1 265 272 self.writeFailedRow( 266 failed_writer, raw_row,273 failed_writer, string_row, 267 274 "This object already exists in the same container. Skipping.") 268 275 continue … … 275 282 num_warns += 1 276 283 self.writeFailedRow( 277 failed_writer, raw_row,284 failed_writer, string_row, 278 285 "%s Skipping." % error.message) 279 286 continue … … 282 289 num_warns += 1 283 290 self.writeFailedRow( 284 failed_writer, raw_row,291 failed_writer, string_row, 285 292 "Cannot remove: no such entry.") 286 293 continue … … 291 298 num_warns += 1 292 299 self.writeFailedRow( 293 failed_writer, raw_row,300 failed_writer, string_row, 294 301 "Cannot update: no such entry.") 295 302 continue -
main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.txt
r6741 r6824 352 352 353 353 If something goes wrong during processing, the respective --IGNORE-- 354 cols w ill be populated correctlyin the resulting pending file:354 cols won't be populated in the resulting pending file: 355 355 356 356 >>> result = processor.doImport('newcomers.csv', ['name', 'dinoports', … … 361 361 362 362 >>> print open(result[3], 'rb').read() 363 --IGNORE--,name,--IGNORE--,dinoports,--ERRORS-- 364 Barney,Barneys Home,1,2,This object already exists in the same container. Skipping. 365 Wilma,Wilmas Asylum,1,1,This object already exists in the same container. Skipping. 366 Fred,Freds Dinoburgers,0,10,This object already exists in the same container. Skipping. 367 Joey,Joeys Drive-in,0,110,This object already exists in the same container. Skipping. 368 369 The first ignored column ('owner') provides different contents than 370 the second one ('taxpayer'). 363 name,dinoports,--ERRORS-- 364 Barneys Home,2,This object already exists in the same container. Skipping. 365 Wilmas Asylum,1,This object already exists in the same container. Skipping. 366 Freds Dinoburgers,10,This object already exists in the same container. Skipping. 367 Joeys Drive-in,110,This object already exists in the same container. Skipping. 368 371 369 372 370 Clean up:
Note: See TracChangeset for help on using the changeset viewer.