def execute_processor(self):
        """
        get the parameters needed for this and run csvsort
        """
        # pull in the parameter that has the file name that we will process
        filename = self.param_dict['sort_file']
        
        # get the path to the file we'll read in
        csv_in = os.path.join(self.entry.working_directory,filename)
        csv_out = self.get_temp_csv_name()
        
        has_header = True if self.param_dict.get('has_header','True') == 'True' else False
        max_size = int(self.param_dict.get('max_size','100'))
        delimiter = self.param_dict.get('delimiter',',')
        
        
        columns = self.param_dict.get('sort_columns','0').split(',')
        columns = [int(column) if column.isdigit() else column for column in columns]
        
        
        global TMP_DIR 
        TMP_DIR = os.path.join(self.entry.working_directory,'.csvsort.%d' % os.getpid())

        csvsort(csv_in, columns, csv_out, max_size, has_header, delimiter)
        return 0
Beispiel #2
0
 def close_temp_csv(self, sort=False):
     if not self.temp_csvfile.closed:
         try:
             self.temp_csvfile.close()
             if sort:
                 filename = self.temp_csvfile.name
                 columns = self.param_dict.get('sort_columns','0').split(',')
                 columns = [int(column) if column.isdigit() else column for column in columns]
                 csvsort(filename, columns)
         except csv.Error as err1:
             self.log_message('could not close the file: ' + str(err1) + " Will continue execution",log_level=self.log_error(),name=self.name,status='error')
             traceback.print_exc()
Beispiel #3
0
    def sort_one_file(self, filename, arg_columns):
        # get the path to the file we'll read in
        csv_in = os.path.join(self.entry.working_directory,filename)
        
        has_header = True
        max_size = int(self.param_dict.get('max_size','100'))
        delimiter = self.param_dict.get('delimiter',',')
        
        
        columns = arg_columns.split(',')
        columns = [int(column) if column.isdigit() else column for column in columns]
        
        
        global TMP_DIR 
        TMP_DIR = os.path.join(self.entry.working_directory,'.csvsort.%d' % os.getpid())

        csvsort(csv_in, columns, None, max_size, has_header, delimiter)
Beispiel #4
0
    def sort_one_file(self, filename, arg_columns):
        # get the path to the file we'll read in
        csv_in = os.path.join(self.entry.working_directory, filename)

        has_header = True
        max_size = int(self.param_dict.get('max_size', '100'))
        delimiter = self.param_dict.get('delimiter', ',')

        columns = arg_columns.split(',')
        columns = [
            int(column) if column.isdigit() else column for column in columns
        ]

        global TMP_DIR
        TMP_DIR = os.path.join(self.entry.working_directory,
                               '.csvsort.%d' % os.getpid())

        csvsort(csv_in, columns, None, max_size, has_header, delimiter)