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'))
评论列表
文章目录