# HG changeset patch # User Jeff Hammel # Date 1415148567 28800 # Node ID f35b646eefa9eb631a814af8faa3b92ac0567484 # Parent 27913386a8a348744cea42ad1c2328d056bb4f79 moar stubbin diff -r 27913386a8a3 -r f35b646eefa9 numerics/convert.py --- a/numerics/convert.py Tue Nov 04 15:54:50 2014 -0800 +++ b/numerics/convert.py Tue Nov 04 16:49:27 2014 -0800 @@ -6,11 +6,14 @@ import argparse import sys -from .read import CSVParser +from .read import read_csv -__all__ = ['cast', 'float_or_orig'] +__all__ = ['cast', 'float_or_orig', 'main'] + +default_cast = (int, float, ) def cast(to_type, *values): + retval = [] for value in values: try: @@ -19,8 +22,15 @@ retval.append(value) return retval + def float_or_orig(*values): - return cast(float, *values) + return cast([float], *values) + + +def cast_column(values, to=default_cast): + """ + cast a column of data + """ def main(args=sys.argv[1:]): """CLI"""