Openpyxl: Typeerror - Concatenation Of Several Columns Into One Cell Per Row
I am new to openpyxl and cannot figure out what the reason for my error is. I hope you can see the problem and show me what to change! What I want to do: I want to concatenate the
Solution 1:
Using openpyxl
, I created a little function that will do what you want for a line at a time:
import openpyxl
theFile = openpyxl.load_workbook('T013.xlsx')
allSheetNames = theFile.sheetnames
print("All sheet names: {}" .format(theFile.sheetnames))
sheet = theFile.active
defconcat_f_to_m(row_value):
values=[]
del values[:]
for row in sheet.iter_rows(min_col=6, max_col=13, min_row=row_value, max_row=row_value):
for cell in row:
if cell.value == None:
passelse:
values.append(str(cell.value))
sheet[f'E{row_value}'].value= ''.join(values)
concat_f_to_m(1)
concat_f_to_m(2)
theFile.save('T013.xlsx')
Output:
Post a Comment for "Openpyxl: Typeerror - Concatenation Of Several Columns Into One Cell Per Row"