n=16
q=0
for x in range(6,int(query)):
for s in range(65,90):
for cell in Cell(sheet,chr(s),x):
for rows in ws.iter_rows():
for cells in rows:
I get an error where
for cell in Cell(sheet,chr(s),x):
self._shared_date = SharedDate(base_date=worksheet.parent.excel_base_date) AttributeError: 'function' object has no attribute 'parent'I am lost as to how to approach this now. I'm trying to copy data from one excel into a new excel file with the idea that my code will methodically go through the two excel files from one cell at a time and copy the data to the other. [below is the follow on from the code at the first block] cell.value = cells.internal_valueif someone can help clarify this for me it would be greatly appreciated. I'm very new to python and openpyxl, and I wish to improve in my python programming skills.
Thank you for that Charlie. It has solved some parts of it, but now I'm trying to find a function within openpyxl which allows me to transfer said data from one file to the dump file. For the new workbook i've used the Workbook() function and get_active_sheet function, but they don't allow me to call on the function
dumpe.append([])
for cell in row:
dumpe[-1].append(cell.value)
count = -1
for row in ws.iter_rows:
count+=1
for cell in row:
cell.value = dumpe[count]
But i think this forces the script to go into an infinte loop. Attached is the script i'm writing.
Could you please advise on where i should go from here onwards?
data = Workbook(filename)
newsheet = worksheet.Worksheet(data, 'Calculations')
ws = data.get_sheet_by_name('17270115')
for col_idx in range(1,40):
col = get_column_letter(col_idx)
for row in range(6,query):
newsheet.append([ws.cell('%s%s'%(col,row)).value])
From several references online where people have used the code, it should work, but the error i'm getting is this
newsheet.append([ws.cell('%s%s'%(col,row)).value])
AttributeError: 'NoneType' object has no attribute 'cell'
It seems like it's the ws is only an instance? Not specifically referring to the actual values inside the cell?
So I tried to use the load_workbook function
data = load_workbook(filename, use_iterators = True)
and the traceback error was this:
newsheet.append([ws.cell('%s%s'%(col,row)).value])
AttributeError: 'NoneType' object has no attribute 'value'
So I'm not sure whether it's the way I'm trying to access the values or is it the type of data within it? The file is a .tst file that is opened in Excel (delimited) and then saved as an Excel workbook. All data are numbers depicting specific readings.
At this point I'm only working on copying raw data into a 'manipulation' worksheet. The end manipulation would be creating columns in between each raw data for manipulation. I believe applying the formulae into those cells is the easy part of this script. It's just the transfer of data and the insertion of the column that might be a bit hard to script out.