def open_csv(path):
"""
Makes sure that the files are opened and closed properly using the
decorator pattern
"""
the_file = open(path, 'ab')
writer = csv.writer(the_file,
dialect='excel',
encoding='utf-8',
delimiter=',',
quotechar='"',
quoting=csv.QUOTE_NONNUMERIC)
yield writer
the_file.close()
评论列表
文章目录