Skip to content
Advertisement

openpyxl delete all values except the column row excel

I have an excel:

JavaScript

So, long is in cell(A1), 5.11 is in cell(B2); I want to clear all the values in suggested_long and suggested_short but need to keep the column name rows as I need to insert data after cleaning all the values. Then the result should be:

JavaScript

I know openpyxl can do like:

JavaScript

to delete the value in the cell, but I have uncertain number of cell values in suggested_long and suggested_short. I assume others may have the same problem, so I post it here, many thanks

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement