Jun-25-2023, 01:42 PM
I wasn't able to get that to work.
If I take a step back and ask it another way - How can I filter the data below to select the numerical data in the Area column that is a part of text within the Name column that contains only the 'nte' letters? I have attempted various wild-card symbols (ie, *, ?). If I can select the data sets I want, then I can determine the mean,stdev functions.
Name column Area
this_is_a_sentence 500
the_color_purple 650
this_is_also_a_sentence 750
If I take a step back and ask it another way - How can I filter the data below to select the numerical data in the Area column that is a part of text within the Name column that contains only the 'nte' letters? I have attempted various wild-card symbols (ie, *, ?). If I can select the data sets I want, then I can determine the mean,stdev functions.
Name column Area
this_is_a_sentence 500
the_color_purple 650
this_is_also_a_sentence 750
(Jun-24-2023, 10:55 PM)Pedroski55 Wrote: 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.
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!')