utils.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:dbs-back 作者: Beit-Hatfutsot 项目源码 文件源码
def collection_to_csv(coll, f):
    '''
        dumps a collection to a csv files.
        the file includes the URL of the hebrew page, its title,
        the url of the english page and its title.
    '''
    from bhs_api.item import SHOW_FILTER
    for i in coll.find(SHOW_FILTER):
        url = slugs_to_urls(i['Slug'])
        try:
            line = ','.join([url['He'], i['Header']['He'].replace(',','|')])
        except KeyError:
            line = ','
        try:
            line = ','.join([line, url['En'], i['Header']['En'].replace(',','|')])
        except KeyError:
            line = ','.join([line, '', ''])
        line += '\n'
        f.write(line.encode('utf8'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号