Im having a hard time trying to delete empty(blank) rows from a csv file using python 3.4.3. Each time I run my script the output remains the same as the original.
import csv
...
with open('demo004.csv') as input, open('demo005.csv', 'w') as output:
writer = csv.writer(output)
for row in csv.reader(input):
if any(field.strip() for field in row):
writer.writerow(row)
input.close()
output.close()
My CSV file is in the format.
AA,AB,AC
BA,BB,BC
CA,CB,CB
Whereas I would like to obtain
AA,AB,AC
BA,BB,BC
CA,CB,CB