57
|
1 #!/usr/bin/env python
|
|
2 # -*- coding: utf-8 -*-
|
|
3
|
|
4 """
|
|
5 manipulate CSV data
|
|
6 """
|
|
7
|
|
8 # imports
|
|
9 import argparse
|
|
10 import os
|
|
11 import sys
|
60
|
12 from .convert import cast_columns
|
|
13 from .read import CSVParser
|
57
|
14
|
|
15 # module globals
|
106
|
16 __all__ = ['ManipulationParser', 'main']
|
57
|
17 here = os.path.dirname(os.path.realpath(__file__))
|
|
18 string = (str, unicode)
|
|
19
|
60
|
20 class ManipulationParser(CSVParser):
|
|
21 """CLI option parser for data manipulation"""
|
|
22
|
57
|
23 def __init__(self, **kwargs):
|
|
24 kwargs.setdefault('description', __doc__)
|
60
|
25 CSVParser.__init__(self, **kwargs)
|
57
|
26 self.options = None
|
|
27
|
60
|
28 def typed_data(self):
|
|
29 raise NotImplementedError('TODO') # -> record TODO items
|
57
|
30
|
|
31 def main(args=sys.argv[1:]):
|
|
32 """CLI"""
|
|
33
|
|
34 # parse command line options
|
106
|
35 parser = ManipulationParser()
|
57
|
36 options = parser.parse_args(args)
|
|
37
|
|
38 if __name__ == '__main__':
|
|
39 main()
|
|
40
|