Mercurial > hg > numerics
view numerics/convert.py @ 32:27913386a8a3
todo
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 04 Nov 2014 15:54:50 -0800 |
parents | a655306ee78d |
children | f35b646eefa9 |
line wrap: on
line source
#!/usr/bin/env python """ convert between types """ import argparse import sys from .read import CSVParser __all__ = ['cast', 'float_or_orig'] def cast(to_type, *values): retval = [] for value in values: try: retval.append(to_type(value)) except ValueError: retval.append(value) return retval def float_or_orig(*values): return cast(float, *values) def main(args=sys.argv[1:]): """CLI""" # parse command line parser = argparse.ArgumentParser(description="interpolate types from file") parser.add_argument('file', type=argparse.FileType('r'), help="CSV file") options = parser.parse_args(args) # read CSV file if __name__ == '__main__': main()