<s> import agate <EOL> from csvkit . cli import CSVKitUtility , parse_column_identifiers <EOL> class CSVSort ( CSVKitUtility ) : <EOL> description = '<STR_LIT>' <EOL> def add_arguments ( self ) : <EOL> self . argparser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> self . argparser . add_argument ( '<STR_LIT:-c>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> self . argparser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> self . argparser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , type = int , <EOL> help = '<STR_LIT>' ) <EOL> self . argparser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> def main ( self ) : <EOL> if self . args . names_only : <EOL> self . print_column_names ( ) <EOL> return <EOL> table = agate . Table . from_csv ( self . input_file , sniff_limit = self . args . sniff_limit , header = not self . args . no_header_row , column_types = self . get_column_types ( ) , ** self . reader_kwargs ) <EOL> column_ids = parse_column_identifiers ( self . args . columns , table . column_names , column_offset = self . get_column_offset ( ) ) <EOL> table = table . order_by ( lambda row : [ ( row [ column_id ] is not None , row [ column_id ] ) for column_id in column_ids ] , reverse = self . args . reverse ) <EOL> table . to_csv ( self . output_file , ** self . writer_kwargs ) <EOL> def launch_new_instance ( ) : <EOL> utility = CSVSort ( ) <EOL> utility . main ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> launch_new_instance ( ) </s>
