Python: How to check if cell in CSV file is empty?

后端 未结 6 1305
天命终不由人
天命终不由人 2020-12-17 02:40

I have a CSV file that I\'m reading in Python and I want the program to skip over the row if the first column is empty. How do I do this?

Right now I have:



        
6条回答
  •  自闭症患者
    2020-12-17 02:56

    You could use try and except.

    for row in csvreader:
            try:
                   #your code for cells which aren't empty
            except:
                   #your code for empty cells
    

提交回复
热议问题