changeset 5:d5447d401c44

serializaion; pandas probably does this
author Jeff Hammel <k0scist@gmail.com>
date Thu, 04 Sep 2014 18:00:04 -0700
parents 097296d6132e
children 7761aa18e885
files numerics/convert.py numerics/read.py
diffstat 2 files changed, 65 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/numerics/convert.py	Thu Sep 04 18:00:04 2014 -0700
@@ -0,0 +1,11 @@
+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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/numerics/read.py	Thu Sep 04 18:00:04 2014 -0700
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+read CSV, etc
+"""
+
+# imports
+import argparse
+import os
+import subprocess
+import sys
+
+# module globals
+__all__ = ['main', 'Parser']
+here = os.path.dirname(os.path.realpath(__file__))
+string = (str, unicode)
+
+def ensure_dir(directory):
+    """ensure a directory exists"""
+    if os.path.exists(directory):
+        assert os.path.isdir(directory)
+        return directory
+    os.makedirs(directory)
+    return directory
+
+def read_csv
+
+class CSVParser(argparse.ArgumentParser):
+    """CLI option parser"""
+    def __init__(self, **kwargs):
+        kwargs.setdefault('description', __doc__)
+        argparse.ArgumentParser.__init__(self, **kwargs)
+        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 main(args=sys.argv[1:]):
+    """CLI"""
+
+    # parse command line options
+    parser = Parser()
+    options = parser.parse_args(args)
+
+if __name__ == '__main__':
+    main()
+