update env

This commit is contained in:
better629 2024-01-23 16:38:42 +08:00
parent 2289763dfe
commit ff6f27f0a3
9 changed files with 46 additions and 8 deletions

View file

@ -604,6 +604,29 @@ def read_csv_to_list(curr_file: str, header=False, strip_trail=True):
return analysis_list[0], analysis_list[1:]
def read_csv_to_list(curr_file: str, header=False, strip_trail=True):
"""
Reads in a csv file to a list of list. If header is True, it returns a
tuple with (header row, all rows)
ARGS:
curr_file: path to the current csv file.
RETURNS:
List of list where the component lists are the rows of the file.
"""
logger.debug(f"start read csv: {curr_file}")
analysis_list = []
with open(curr_file) as f_analysis_file:
data_reader = csv.reader(f_analysis_file, delimiter=",")
for count, row in enumerate(data_reader):
if strip_trail:
row = [i.strip() for i in row]
analysis_list += [row]
if not header:
return analysis_list
else:
return analysis_list[0], analysis_list[1:]
def import_class(class_name: str, module_name: str) -> type:
module = importlib.import_module(module_name)
a_class = getattr(module, class_name)