changeset 110:5790bcb30bd8

moar stubbin
author Jeff Hammel <k0scist@gmail.com>
date Sun, 15 Mar 2015 15:28:15 -0700
parents fae24f57dcb1
children c4d26ef63d8e
files numerics/manipulate.py numerics/read.py
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- 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()