📜  过滤空白行 python csv - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:02.808000             🧑  作者: Mango

代码示例1
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))