Answers for "csv remove empty rows"

1

filter blank rows python csv

def no_blank(fd):
    try:
        while True:
            line = next(fd)
            if len(line.strip()) != 0:
                yield line
    except:
        return
#Read the CSV file.
with open('campaign_monthly_report.csv', 'r') as csv_file:
    csv_reader = csv.DictReader(no_blank(csv_file))
Posted by: Guest on June-19-2021
0

python csv delete all rows

filename = "filewithcontents.csv"
# opening the file with w+ mode truncates the file
f = open(filename, "w+")
f.close()
Posted by: Guest on November-19-2021

Code answers related to "csv remove empty rows"

Python Answers by Framework

Browse Popular Code Answers by Language