def fmt(val, dtype): if dtype == 'date': return vutils.dateFloatToString(val) elif dtype == 'numeric': return '%0.5g' % val elif dtype == 'text': return val else: raise RuntimeError