0

I am using the csv module to read in csv files to do data analysis.

data = []
c1 = []
c2 = []
c3 = []
data_file = csv.reader(open('file.csv'))
for row in data_file:
       data.append(row)
for i in data:
       c1.append(data[i][0])
       c2.append(data[i][1])
       c3.append(data[i][2])

How do I replace the empty cells with 0?

1 Answers1

0

before appending your data you could do a check similar to what is found here :

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

When the condition is true, simply append 0 to your corresponding cell (c1, c2, c3)

Community
  • 1
  • 1