changeset 60:e3c3ee7b5ccf

stubbing manipulate data
author Jeff Hammel <k0scist@gmail.com>
date Thu, 22 Jan 2015 13:33:56 -0800
parents 3781174542bb
children 82a18c9337c3
files numerics/convert.py numerics/manipulate.py
diffstat 2 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/convert.py	Tue Jan 20 16:50:42 2015 -0800
+++ b/numerics/convert.py	Thu Jan 22 13:33:56 2015 -0800
@@ -48,7 +48,8 @@
     cast a column of data
     """
     column_types = [column_type(column) for column in columns]
-    raise NotImplementedError('TODO') # -> record TODO items
+    return [[column_type(row) for row in column]
+            for column_type, column in zip(column_types, columns)]
 
 
 def main(args=sys.argv[1:]):
--- a/numerics/manipulate.py	Tue Jan 20 16:50:42 2015 -0800
+++ b/numerics/manipulate.py	Thu Jan 22 13:33:56 2015 -0800
@@ -8,30 +8,28 @@
 # imports
 import argparse
 import os
-import subprocess
 import sys
+from .convert import cast_columns
+from .read import CSVParser
 
 # module globals
-__all__ = ['main', 'Parser']
+__all__ = ['main', 'ManipulationParser']
 here = os.path.dirname(os.path.realpath(__file__))
 string = (str, unicode)
 
-class Parser(argparse.ArgumentParser):
-    """CLI option parser"""
+class ManipulationParser(CSVParser):
+    """CLI option parser for data manipulation"""
+
     def __init__(self, **kwargs):
-        kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)
         kwargs.setdefault('description', __doc__)
-        argparse.ArgumentParser.__init__(self, **kwargs)
+        CSVParser.__init__(self, **kwargs)
+        self.add_argument('--list', '--entries', '--list-entries',
+                          dest='list_entries', nargs='?', const=0, type=int,
+                          help="list all entries for this column")
         self.options = None
 
-    def parse_args(self, *args, **kw):
-        options = argparse.ArgumentParser.parse_args(self, *args, **kw)
-        self.validate(options)
-        self.options = options
-        return options
-
-    def validate(self, options):
-        """validate options"""
+    def typed_data(self):
+        raise NotImplementedError('TODO') # -> record TODO items
 
 def main(args=sys.argv[1:]):
     """CLI"""
@@ -40,6 +38,9 @@
     parser = Parser()
     options = parser.parse_args(args)
 
+    if options.list_entries:
+        raise NotImplementedError('TODO') # -> record TODO items
+
 if __name__ == '__main__':
     main()