Jun-24-2023, 10:55 PM
Not a mathematician, don't know about standard deviation or pandas.
This will get your data as a list of tuples. You can work on it then.
This will get your data as a list of tuples. You can work on it then.
import openpyxl import re # open the XL path2XL = '/home/pedro/myPython/openpyxl/xlsx_files/get_data1.xlsx' sourceFile = openpyxl.load_workbook(path2XL) # always good to get the sheet names, you can loop through them if you need to sourceFilesheets = sourceFile.sheetnames mysheet = 'Standard' # you often need these 2 to loop along or down an XL maxRow = sourceFile[mysheet].max_row maxCol = sourceFile[mysheet].max_column # if your column is H, that is column 8 # openpyxl does have a "get column number from letter" function, but H is column 8 # I assume your data starts in row 2 change that if needed # loop through all the rows and collect your data results = [] for rowNum in range(2, maxRow + 1): mystring = sourceFile[mysheet].cell(row=rowNum, column=8).value # split the string on space, the number you want is at the end, separated by a space I think! mydata = mystring.split() # re.search only returns 1 instance, I believe mystd = re.search(r'std\d\d', mydata[0]) mynumber = int(mydata[1]) mytup = ('Row ' + str(rowNum), mystd[0], mynumber) results.append(mytup) for data in results: print(data) print('Gotcha!')