Author: johannes
Date: 2005-07-06 08:14:11 -0500 (Wed, 06 Jul 2005)
New Revision: 7689

Modified:
   trunk/gnue-common/src/utils/dbf.py
Log:
Transfor empty fields to python's None value


Modified: trunk/gnue-common/src/utils/dbf.py
===================================================================
--- trunk/gnue-common/src/utils/dbf.py  2005-07-06 13:06:21 UTC (rev 7688)
+++ trunk/gnue-common/src/utils/dbf.py  2005-07-06 13:14:11 UTC (rev 7689)
@@ -197,8 +197,12 @@
       raw = stream [cpos:cpos + flen]
       cpos += flen
 
+      # Is the field empty ?
+      if not raw.strip ():
+        value = None
+
       # Numeric conversion
-      if ftype == 'N':
+      elif ftype == 'N':
         if fdec:
           value = float (raw.split ('\x00', 1) [0].strip () or 0)
         else:
@@ -268,7 +272,7 @@
 
 if __name__ == '__main__':
 
-  dbfile = dbf ('/home/johannes/dat_cli.dbf')
+  dbfile = dbf ('/home/johannes/checkit.dbf')
 
   print "STATs:"
   print "  Signature:", dbfile.signature



_______________________________________________
Commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue

Reply via email to