Python Forum
find empty cells in a column
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find empty cells in a column
#1
I have a results sheet from a multiple choice marking program. I only need to check if there is no content in a particular cell.

Lets say we are looking at column F of an excel table. Each row from row 2 to sheet.max_row should have an entry, a letter from A, B, C or D. These letters are assigned by a program which marks multiple choice forms.

What I am looking for is cells which have no entry.

for rowNum in range(2, sheet.max_row):
	print(sheet.cell(row=rowNum, column=6).value)
This output looks like this:

Quote:D
C
B
None
D
A
A

In this example, F5 has no content. So I will assign the student number in B5 to studentNumbersWithErrors[]

What I want is to find any cells in all even columns from F onwards which have no content. If there is no content, I want the student number, which is in column B. The row is rowNum. Then I can check in the marking program to see what the problem is. That way, I only need to check if there is a problem.

I've tried:
Quote:if sheet.cell(row=rowNum, column=6).value = 'None':
if sheet.cell(row=rowNum, column=6).value = None:
if sheet.cell(row=rowNum, column=6).value = '':

I keep getting 'syntax error'. Any tips please?
Reply
#2
You missed double equals to sign (==) inside if conditional statement.
Reply
#3
Haha, thanks, that did it. I got what I wanted!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find a string from a column of one table in another table visedwings049 8 1,180 Sep-07-2023, 03:22 PM
Last Post: deanhystad
  [SOLVED] [sqilte3] Check if column not empty? Winfried 5 1,130 Jan-28-2023, 12:53 PM
Last Post: Winfried
  Openpyxl-change value of cells in column based on value that currently occupies cells phillipaj1391 5 9,868 Mar-30-2022, 11:05 PM
Last Post: Pedroski55
  Find last filled column in openpyxl Irv1n 2 12,836 Jan-16-2022, 11:05 AM
Last Post: Pedroski55
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,322 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  OpenPyxl: How to iterate through each Column (in 1 row) to find a value? chatguy 2 18,092 Apr-06-2021, 04:52 AM
Last Post: carlhyde
  How can I iterate through all cells in a column (with merge cells) with openpyxl? aquerci 1 7,533 Feb-11-2021, 09:31 PM
Last Post: nilamo
  Copy certain cells into new workbook certain cells Kristenl2784 4 2,504 Jul-14-2020, 07:59 PM
Last Post: Kristenl2784
  write to excel will be empty in column jacklee26 7 3,387 Jun-27-2020, 12:09 AM
Last Post: snippsat
  How to get previous non empty value of another column klllmmm 1 1,811 Feb-02-2020, 12:22 PM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020