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
|
108
|
12 from .convert import default_cast, cast_columns
|
60
|
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
|
108
|
23 types = default_cast
|
|
24
|
57
|
25 def __init__(self, **kwargs):
|
|
26 kwargs.setdefault('description', __doc__)
|
60
|
27 CSVParser.__init__(self, **kwargs)
|
57
|
28 self.options = None
|
|
29
|
60
|
30 def typed_data(self):
|
108
|
31 """return parsed and casted data"""
|
60
|
32 raise NotImplementedError('TODO') # -> record TODO items
|
57
|
33
|
|
34 def main(args=sys.argv[1:]):
|
|
35 """CLI"""
|
|
36
|
|
37 # parse command line options
|
106
|
38 parser = ManipulationParser()
|
57
|
39 options = parser.parse_args(args)
|
|
40
|
|
41 if __name__ == '__main__':
|
|
42 main()
|