Using csvreader against a gzipped file in Python

前端 未结 3 872
無奈伤痛
無奈伤痛 2020-12-25 11:35

I have a bunch of gzipped CSV files that I\'d like to open for inspection using Python\'s built in CSV reader. I\'d like to do this without having first to manually unzip t

3条回答
  •  借酒劲吻你
    2020-12-25 11:50

    Use the gzip module:

    with gzip.open(filename, mode='rt') as f:
        reader = csv.reader(f)
        #...
    

提交回复
热议问题