import openpyxl as pyxl
from functions import myFunction
wb = pyxl.load_workbook("data.xlsx")
myDF = pd.DataFrame(columns=cols, index=rows)
The code below works, when I pass in the workbook and dataframe
myFunction(wb, myDF)
but if it doesn't work if I declare global variables within the import function, getting an error of 'NameError: name 'wb' is not defined.' so I don't believe it's recognising the global variable from the main script. Any ideas of what I'm doing wrong?
#from the imported code
myFunction():
global wb
global myDF
ws = wb['Sheet1']
#run from the main script
myFunction()