I am trying to take many rows of excel files and parse them. I have multiple rows of 60 numbers. I would like to make a new stack or row every 4 numbers for every single row. I know this is confusing, an example would be:
input from excel 0.282836353 0.287834898 0.284861334 0.284880417 0.242768564 0.241888021 0.240441747 0.244627766 0.245007869 0.244790578 0.243485108 0.244743911 0.267488959 0.264294548 0.267708093 0.268158158
output: 0.282836353 0.287834898 0.284861334 0.284880417
0.242768564 0.241888021 0.240441747 0.244627766
0.245007869 0.244790578 0.243485108 0.244743911
0.267488959 0.264294548 0.267708093 0.268158158
This is what I currently have tried:
import openpyxl
excelFile = openpyxl.load_workbook("nameoffile.xlsx")
sheet = excelFile["Sheet1"]
nRows = sheet.max_row
nCols = sheet.max_column
r = 2
groups = 4 # how many to be grouped together
parsedList = []
while r <= nRows:
rList,rListSum = [],[]
x = 0
c = 2
while c <= nCols:
if x < groups:
cell = sheet.cell(row=r,column=c)
rList.append(cell.value)
x += 1
if x == groups:
rListSum.append(rList)
c += 1
parsedList.append(rListSum)
r += 1
my current output is nothing. something seems to be wrong with my loop.
