OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Delete_cols function not deleting columns in Excel sheet

  • Thread starter Thread starter Jaheen
  • Start date Start date
J

Jaheen

Guest
I'm working on code to delete columns in an Excel sheet, and I'm trying to figure out why columns are not being deleted from my delete_cols function call with openpyxl. Here is the snippet of code I have to do that:

Code:
i=4
    for column in sheet.iter_cols(min_col=5):
        i+=1
        name=column[0].value
        if name not in names_of_employees:
            sheet.delete_cols(i, amount=1)

There's a chance I'm misunderstanding the delete_cols function, so feel free to tell me if that's the case. I did double-check the column contents as well as the worksheet I'm trying to delete from, and those both seem to be correct. Would you guys happen to know why this is happening?
<p>I'm working on code to delete columns in an Excel sheet, and I'm trying to figure out why columns are not being deleted from my <code>delete_cols</code> function call with <code>openpyxl</code>. Here is the snippet of code I have to do that:</p>
<pre><code>i=4
for column in sheet.iter_cols(min_col=5):
i+=1
name=column[0].value
if name not in names_of_employees:
sheet.delete_cols(i, amount=1)
</code></pre>
<p>There's a chance I'm misunderstanding the <code>delete_cols</code> function, so feel free to tell me if that's the case. I did double-check the column contents as well as the worksheet I'm trying to delete from, and those both seem to be correct. Would you guys happen to know why this is happening?</p>
 

Latest posts

Top