# HG changeset patch # User Jeff Hammel # Date 1426458495 25200 # Node ID 5790bcb30bd80ee82d1ecf50afb18824444390c9 # Parent fae24f57dcb16eb524e179d19d3e2d9b50a48ba3 moar stubbin diff -r fae24f57dcb1 -r 5790bcb30bd8 numerics/manipulate.py --- a/numerics/manipulate.py Sun Mar 15 10:49:29 2015 -0700 +++ b/numerics/manipulate.py Sun Mar 15 15:28:15 2015 -0700 @@ -10,12 +10,12 @@ import os import sys from .convert import default_cast, cast_columns +from .data import transpose from .read import CSVParser # module globals __all__ = ['ManipulationParser', 'main'] -here = os.path.dirname(os.path.realpath(__file__)) -string = (str, unicode) + class ManipulationParser(CSVParser): """CLI option parser for data manipulation""" @@ -29,7 +29,10 @@ def typed_data(self): """return parsed and casted data""" - raise NotImplementedError('TODO') # -> record TODO items + return cast_columns(self.columns(), self.types) + + def process(self): + return transpose(self.typed_data()) def main(args=sys.argv[1:]): """CLI""" @@ -38,5 +41,8 @@ parser = ManipulationParser() options = parser.parse_args(args) + # write manipulated data + parser.write(parser.process()) + if __name__ == '__main__': main() diff -r fae24f57dcb1 -r 5790bcb30bd8 numerics/read.py --- a/numerics/read.py Sun Mar 15 10:49:29 2015 -0700 +++ b/numerics/read.py Sun Mar 15 15:28:15 2015 -0700 @@ -148,6 +148,10 @@ """return columns vs `data`'s rows""" return transpose(self.read()) + def write(self, data): + """write data to specified CSV destination""" + # TODO: support more formats + CSVWriter(self.options.output).write(data) def main(args=sys.argv[1:]): """CLI""" @@ -170,9 +174,7 @@ data = parser.read() # write CSV - writer = CSVWriter(options.output) - writer.write(data) - + parser.write(data) if __name__ == '__main__': main()