How to delete rows that satisfy some criteria in an excel spreadsheet?

前端 未结 2 1020
一个人的身影
一个人的身影 2021-01-04 04:10

I would like to create a \"reduced\" version of an Excel (xlsx) spreadsheet (i.e. by removing some rows according to some criterion), and I\'d like to know if this can be do

2条回答
  •  迷失自我
    2021-01-04 04:38

    2018 update: I was searching how to delete a row today and found that the functionality is added in openpyxl 2.5.0-b2. Just tried and it worked perfectly. Here's the link where I found the answer: https://bitbucket.org/openpyxl/openpyxl/issues/964/delete_rows-does-not-work-on-deleting

    And here's the syntax to delete one row:

    ws.delete_rows(index, 1)
    

    where: 'ws' is the worksheet, 'index' is the row number, and '1' is the number of rows to delete.

    There's also the ability to delete columns, but I haven't tried that.

提交回复
热议问题