Mercurial > hg > numerics
changeset 33:f35b646eefa9
moar stubbin
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 04 Nov 2014 16:49:27 -0800 |
parents | 27913386a8a3 |
children | dea01adf33dc |
files | numerics/convert.py |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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"""