# HG changeset patch # User Jeff Hammel # Date 1421456923 28800 # Node ID ef915968d104bb0ccfe07984972a0c490b7aeaf7 # Parent 7927d7127f9abcf6edcc8b7149102f3cb5de68ee put this in the parser so that i can use this in convert diff -r 7927d7127f9a -r ef915968d104 numerics/convert.py --- a/numerics/convert.py Fri Jan 09 14:17:33 2015 -0800 +++ b/numerics/convert.py Fri Jan 16 17:08:43 2015 -0800 @@ -10,7 +10,7 @@ __all__ = ['cast', 'float_or_orig', 'main'] -default_cast = (int, float, ) +default_cast = (int, float, str) def cast(to_type, *values): diff -r 7927d7127f9a -r ef915968d104 numerics/read.py --- a/numerics/read.py Fri Jan 09 14:17:33 2015 -0800 +++ b/numerics/read.py Fri Jan 16 17:08:43 2015 -0800 @@ -115,6 +115,30 @@ def validate(self, options): """validate options""" + def read(self): + """read and process CSV""" + + data = read_csv(*self.options.csv) + + if self.options.added_columns: + # add columns + for row in data: + row.extend(options.added_columns) + + if self.options.columns: + # filter by column + data = [[row[column] for column in self.options.columns] + for row in data] + + if self.options.index: + # prepend numeric index + for index, row in enumerate(data): + row.insert(0, index) + + # return processed data + return data + + def main(args=sys.argv[1:]): """CLI""" @@ -127,22 +151,7 @@ options.csv = [sys.stdin] # read CSV - data = read_csv(*options.csv) - - if options.added_columns: - # add columns - for row in data: - row.extend(options.added_columns) - - if options.columns: - # filter by column - data = [[row[column] for column in options.columns] - for row in data] - - if options.index: - # prepend numeric index - for index, row in enumerate(data): - row.insert(0, index) + data = parser.read() # write CSV writer = csv.writer(options.output) diff -r 7927d7127f9a -r ef915968d104 setup.py --- a/setup.py Fri Jan 09 14:17:33 2015 -0800 +++ b/setup.py Fri Jan 16 17:08:43 2015 -0800 @@ -1,5 +1,5 @@ """ -setup packaging script for numerics +setup packaging script for numerics python package """ import os