Replacing Empty Cells with 0 in Python 3
<p>I am using the csv module to read in csv files to do data analysis. </p>

<pre><code>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])
</code></pre>

<p>How do I replace the empty cells with 0?</p>

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

<p><a href="http://stackoverflow.com/questions/34192705/python-how-to-check-if-cell-in-csv-file-is-empty">Python: How to check if cell in CSV file is empty?</a></p>

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

python csv