def do_save_input_table(self,c): flags, args = self.parse_command_line(c) if not self.current_param_db: if len(args) == 0: utils.newline_msg("WRN", "database not loaded nor provided. skipping", 2) return elif len(args) > 1: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return else: self.do_load(args[0]) else: if len(args) > 0: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return if "sep" in flags: self.do_set_separator( flags["sep"] ) self.do_setup_vars_in_table("--all") header, data = self.current_param_db.values_set_table() output_fname = utils.fix_filename("%s/%s_valueset.csv" % (self.current_param_db.path, self.current_param_db.base_name)) print " +- table: '%s'" % output_fname writer = csv.writer(open(output_fname, "w"), delimiter=self.sep, lineterminator="\n") writer.writerow(header) writer.writerows(data)
def do_save_input_table(self, c): flags, args = self.parse_command_line(c) if not self.current_param_db: if len(args) == 0: utils.newline_msg( "WRN", "database not loaded nor provided. skipping", 2) return elif len(args) > 1: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return else: self.do_load(args[0]) else: if len(args) > 0: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return if "sep" in flags: self.do_set_separator(flags["sep"]) self.do_setup_vars_in_table("--all") header, data = self.current_param_db.values_set_table() output_fname = utils.fix_filename( "%s/%s_valueset.csv" % (self.current_param_db.path, self.current_param_db.base_name)) print(" +- table: '%s'" % output_fname) writer = csv.writer(open(output_fname, "w"), delimiter=self.sep, lineterminator="\n") writer.writerow(header) writer.writerows(data)
def do_save_table(self,c): """save_table [-flag1 -flag2] saves the table values in ascii format. default is averaging column values by variable values FLAGS::: --noheader: does not output column names in the output file --raw: raw values without average --full: all simulation ids and variables are output in table (implies raw) --id: only the id is output --sep: column separator ('blank' for space) """ flags, args = self.parse_command_line(c) if not self.current_param_db: if len(args) == 0: utils.newline_msg("WRN", "database not loaded nor provided. skipping", 2) return elif len(args) > 1: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return else: self.do_load(args[0]) else: if len(args) > 0: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return if len( set([ 'raw', "full", "id" ]).intersection( flags ) ) > 1: utils.newline_msg("ERR", "only one flag [raw, full, id] can be active at a time" ) return table_selector = "grouped_vars" if "raw" in flags: table_selector = "raw_vars" elif "id" in flags: table_selector = "only_uid" elif "full" in flags: table_selector = "full" if "sep" in flags: self.do_set_separator(flags["sep"]) for outer_params in self.current_param_db: for table in self.current_param_db.table_columns.keys(): # print i gen_d = utils.generate_string(outer_params, self.current_param_db.separated_vars, joining_string = "/" ) if gen_d: gen_d+= "/" gen_s = utils.generate_string(outer_params, self.current_param_db.coalesced_vars, joining_string="_") output_fname = utils.fix_filename("%s%s_%s-%s.csv" % (gen_d, self.current_param_db.base_name, table, gen_s)) d,f = os.path.split(output_fname) if d != "" and not os.path.exists(d): os.makedirs(d) header, data= self.current_param_db.result_table(table = table , table_selector = table_selector) print " +- table: '%s'" % (output_fname) writer = csv.writer(open(output_fname, "w"), delimiter=self.sep, lineterminator="\n") if not( "noheader" in flags or "append" in flags): writer.writerow( header ) writer.writerows( data )
def do_save_table(self, c): """save_table [-flag1 -flag2] saves the table values in ascii format. default is averaging column values by variable values FLAGS::: --noheader: does not output column names in the output file --raw: raw values without average --full: all simulation ids and variables are output in table (implies raw) --id: only the id is output --sep: column separator ('blank' for space) """ flags, args = self.parse_command_line(c) if not self.current_param_db: if len(args) == 0: utils.newline_msg( "WRN", "database not loaded nor provided. skipping", 2) return elif len(args) > 1: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return else: self.do_load(args[0]) else: if len(args) > 0: utils.newline_msg("ERR", "only one db can be loaded at a time", 2) return if len(set(['raw', "full", "id"]).intersection(flags)) > 1: utils.newline_msg( "ERR", "only one flag [raw, full, id] can be active at a time") return table_selector = "grouped_vars" if "raw" in flags: table_selector = "raw_vars" elif "id" in flags: table_selector = "only_uid" elif "full" in flags: table_selector = "full" if "sep" in flags: self.do_set_separator(flags["sep"]) for outer_params in self.current_param_db: for table in list(self.current_param_db.table_columns.keys()): # print i gen_d = utils.generate_string( outer_params, self.current_param_db.separated_vars, joining_string="/") if gen_d: gen_d += "/" gen_s = utils.generate_string( outer_params, self.current_param_db.coalesced_vars, joining_string="_") output_fname = utils.fix_filename( "%s%s_%s-%s.csv" % (gen_d, self.current_param_db.base_name, table, gen_s)) d, f = os.path.split(output_fname) if d != "" and not os.path.exists(d): os.makedirs(d) header, data = self.current_param_db.result_table( table=table, table_selector=table_selector) print(" +- table: '%s'" % (output_fname)) writer = csv.writer(open(output_fname, "w"), delimiter=self.sep, lineterminator="\n") if not ("noheader" in flags or "append" in flags): writer.writerow(header) writer.writerows(data)