def grab_data(input_file): """Extracts data from an excel file in directory/filename. Data is used to create/return an Experiment object. Precondition: input file is formatted according to generate_sheet/generate_template @type input_file: path @rtype: Experiment """ # Accessing the file from which data is to be grabbed # input_file = os.path.join(directory, filename) input_book = open_workbook(input_file) input_sheet = input_book.sheet_by_index(0) # List where all run info is stored with RunObjects as ind. entries all_analysis_objects = [] # Parsing elution times, correcting for header offset (8) raw_elution_times = input_sheet.col(1) # Col w/elution times given in file elut_ends = [float(x.value) for x in raw_elution_times[8:]] for col_index in range(2, input_sheet.row_len(0)): # Grab individual CATE values of interest run_name = str(input_sheet.cell(0, col_index).value) # in case name is # SA = input_sheet.cell(1, col_index).value root_cnts = input_sheet.cell(2, col_index).value shoot_cnts = input_sheet.cell(3, col_index).value root_weight = input_sheet.cell(4, col_index).value g_factor = input_sheet.cell(5, col_index).value load_time = input_sheet.cell(6, col_index).value # Grabbing elution cpms, correcting for header offset (8) raw_cpm_column = input_sheet.col(col_index)[8:] # Raw counts given by file raw_cpms = [] elution_cpms = [] for item in raw_cpm_column: raw_cpms.append(item.value) if item.value != '': elution_cpms.append(float(item.value)) else: elution_cpms.append(0.0) temp_run = Objects.Run( run_name, SA, root_cnts, shoot_cnts, root_weight, g_factor, load_time, elut_ends, raw_cpms, elution_cpms) all_analysis_objects.append(Objects.Analysis( kind=None, obj_num_pts=None, run=temp_run)) return Objects.Experiment(os.path.dirname(input_file), all_analysis_objects)