error when fixing utf8 in rows with null values
authorEgon Valdmees <egon.valdmees@skype.net>
Tue, 31 May 2011 11:58:59 +0000 (14:58 +0300)
committerEgon Valdmees <egon.valdmees@skype.net>
Tue, 31 May 2011 12:12:30 +0000 (15:12 +0300)
python/londiste/handlers/dispatch.py

index 72704ac2ec443d3624087c9f121ed384319fbcd7..83d7bc092c56699c53f661f961eab0d93cc3eb56 100644 (file)
@@ -613,12 +613,12 @@ class EncodingValidator:
             return _unicode.encode(self.encoding)
 
     def validate_dict(self, data):
-        _cols, _vals = zip(*data.items())
-        _fixed = self.validate('\t'.join(_vals), _cols)
-        if self.error_count == 0:
-            return data
-        else:
-            return dict(zip(_cols, _fixed.split('\t')))
+        for _key, _val in data.items():
+            if _val:
+                _fixed = self.validate(_val, [_key])
+                if self.error_count != 0:
+                    data[_key] = _fixed
+        return data