def createConfigTable(csv_file): """Creates new config table from a properly formatted csv file.""" reader = csv.reader(csv_file) configTableName = parseTableName(reader) # Get the column names cols = next(reader) configs = [] for config in reader: missing_cols = len(cols) - len(config) for i in range(missing_cols): config.append("") configs.append(config) db = DatabaseManager() db.addConfigTable(configTableName, cols, configs) return configTableName
def createConfigTable(csv_file): """Creates new config table from a properly formatted csv file.""" reader = csv.reader(csv_file) configTableName = parseTableName(reader) # Get the column names cols = next(reader) configs = [] for config in reader: missing_cols = len(cols) - len(config) for i in range(missing_cols): config.append("") configs.append(config) db = DatabaseManager() db.addConfigTable(configTableName, cols, configs) return configTableName
def generateConfigTable(gen_file): """Generates config table from csv file of valid config parameters.""" reader = csv.reader(gen_file) configTableName = parseTableName(reader) cols = [] colDict = {} for line in gen_file: if not line.startswith("#"): line = line.strip() key, tokens = line.split("|") key = key.strip() tokens = tokens.strip() cols.append(key) values = [] for token in tokens.split(","): parts = token.split("-") if len(parts) == 2: start, stop = parts step = "1" if ":" in stop: stop, step = stop.split(":") if "." in start + stop + step: vals = frange(float(start), float(stop), float(step)) else: vals = range(int(start), int(stop) + 1, int(step)) values.extend(vals) else: values.append(token) colDict[key] = values configs = [] for col in cols: configs = generateCombos(configs, colDict[col]) db = DatabaseManager() db.addConfigTable(configTableName, cols, configs) return configTableName
def generateConfigTable(gen_file): """Generates config table from csv file of valid config parameters.""" reader = csv.reader(gen_file) configTableName = parseTableName(reader) cols = [] colDict = {} for line in gen_file: if not line.startswith('#'): line = line.strip() key, tokens = line.split('|') key = key.strip() tokens = tokens.strip() cols.append(key) values = [] for token in tokens.split(','): parts = token.split('-') if len(parts) == 2: start, stop = parts step = '1' if ':' in stop: stop, step = stop.split(':') if '.' in start + stop + step: vals = frange(float(start), float(stop), float(step)) else: vals = range(int(start), int(stop) + 1, int(step)) values.extend(vals) else: values.append(token) colDict[key] = values configs = [] for col in cols: configs = generateCombos(configs, colDict[col]) db = DatabaseManager() db.addConfigTable(configTableName, cols, configs) return configTableName