import sys from importlib import reload class FromU2ExcelFile(): def __init__(self): print('Loading variables ') self.workbook = '' self.worksheet = '' def load_csv(self): try: print('At top of method, load_csv_from_file()') if "Workbook" not in sys.modules: # I'm trying to see if openpyxl is loaded, if not load library #print('modules are ', sys.modules) print('loading openpyxl library') import openpyxl else: # if openpyxl is loaded then just reload it. print('RELOADING openpyxl library') openpyxl = reload(openpyxl) print('Just after import openpyxl line ') self.workbook = openpyxl.Workbook() self.worksheet = self.workbook.active except Exception as err1: print('load csv error ', err1) print('ran load_csv()') #exit() return 0 def start_U2excel(self): try: #print ("started thread") #p = multiprocessing.Process(target=self.load_csv()) #p.start() # waiting until process is finished #p.join() #print('END') #self.load_csv() print('loaded start_U2excel method ') self.load_csv() except Exception as err: print (f'Error: unable to start process exception is **** {err}' ) return 0 def build_u2_object(): try: print('Called build_u2_object') my_instance = FromU2ExcelFile() print('return control to U2') except Exception as err: print(f'build_u2_opbject - Exception occured : {err}' ) return my_instance