# HG changeset patch # User Jeff Hammel # Date 1421799160 28800 # Node ID ecaf1d4b1c2caeded18479a95d583ca6565925cf # Parent bbfe25d23a9ff0f0dfe6a642111cb5e520dfe523 this should work now; it doesnt, but it should diff -r bbfe25d23a9f -r ecaf1d4b1c2c numerics/convert.py --- a/numerics/convert.py Tue Jan 20 15:54:06 2015 -0800 +++ b/numerics/convert.py Tue Jan 20 16:12:40 2015 -0800 @@ -4,7 +4,9 @@ convert between types """ +# imports import argparse +import csv import sys from .data import transpose from .read import read_csv, CSVParser @@ -30,6 +32,15 @@ def column_type(values, types=default_cast): """determine the type of a column""" + for t in types: + for value in values: + try: + t(value) + except TypeError: + break + else: + return t + raise NotImplementedError('TODO') # -> record TODO items def cast_column(values, to=default_cast): @@ -48,10 +59,16 @@ # read CSV file data = parser.read() - import pdb; pdb.set_trace() + # transpose + columns = transpose(data) + + # get types + types = [column_type(column) for column in columns] # print type information - raise NotImplementedError('TODO') # -> record TODO items + writer = csv.writer(sys.stdout) + writer.writerow(types) + if __name__ == '__main__': main()