Browse Source

handle empty cells

Joe Shochet 19 years ago
parent
commit
f32e428609
1 changed files with 16 additions and 12 deletions
  1. 16 12
      direct/src/showbase/ExcelHandler.py

+ 16 - 12
direct/src/showbase/ExcelHandler.py

@@ -40,18 +40,22 @@ class ExcelHandler(saxutils.DefaultHandler):
             pass
             pass
         elif name=="Cell":
         elif name=="Cell":
             s = ''.join(self.chars)
             s = ''.join(self.chars)
-            if self.isNumber:
-                # Determine if it is an int or float and use
-                # return the best fit
-                floatVersion = float(s)
-                intVersion = int(floatVersion)
-                if floatVersion == intVersion:
-                    # If the float is equal to the int, it must be an int
-                    s = intVersion
-                else:
-                    # Keep the precision and return a float
-                    s = floatVersion
-            self.cells.append(s)
+            if s:
+                if self.isNumber:
+                    # Determine if it is an int or float and use
+                    # return the best fit
+                    floatVersion = float(s)
+                    intVersion = int(floatVersion)
+                    if floatVersion == intVersion:
+                        # If the float is equal to the int, it must be an int
+                        s = intVersion
+                    else:
+                        # Keep the precision and return a float
+                        s = floatVersion
+                # Convert the string "None" to the python object None
+                elif s == "None":
+                    s = None
+                self.cells.append(s)
         elif name=="Row":
         elif name=="Row":
             self.rows.append(self.cells)
             self.rows.append(self.cells)
         elif name=="Table":
         elif name=="Table":