Mercurial > hg > numerics
view numerics/convert.py @ 48:36e47061187f
stub a transposition function
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 19 Jan 2015 12:38:51 -0800 |
parents | 6d34c02f7c9c |
children | 37838ae694d2 |
line wrap: on
line source
#!/usr/bin/env python """ convert between types """ import argparse import sys from .read import read_csv, CSVParser __all__ = ['cast', 'float_or_orig', 'main'] default_cast = (int, float, str) 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 column_type(values, types=default_cast): """determine the type of a column""" raise NotImplementedError('TODO') # -> record TODO items def cast_column(values, to=default_cast): """ cast a column of data """ raise NotImplementedError('TODO') # -> record TODO items def main(args=sys.argv[1:]): """CLI""" # parse command line parser = CSVParser(description="interpolate types from file") options = parser.parse_args(args) # read CSV file data = parser.read() import pdb; pdb.set_trace() # print type information raise NotImplementedError('TODO') # -> record TODO items if __name__ == '__main__': main()