def toIntSafely(d): try: s = str(d) i = int(s) except: i = 0 return i