我有一个大字典(输出为 366MB 中的字符串,~383764153 行文件文本文件),我想将其存储在数据库中以便快速访问并跳过填充字典所涉及的计算时间。
我的字典由文件名/内容对字典组成。小子集:
{
'Reuters/19960916': {
'54826newsML': '<?xml version="1.0"
encoding="iso-8859-1" ?>\r\n<newsitem itemid="54826" id="root"
date="1996-09-16" xml:lang="en">\r\n<title>USA: RESEARCH ALERT -
Crestar Financial cut.</title>\r\n<headline>RESEARCH ALERT - Crestar
Financial cut.</headline>\r\n<text>\n<p>-- Salomon Brothers analyst
Carole Berger said she cut her rating on Crestar Financial Corp to
hold from buy, at the same time lowering her 1997 earnings per share
view to $5.40 from $5.85.</p>\n<p>-- Crestar said it would buy
Citizens Bancorp in a $774 million stock swap.</p>\n<p>-- Crestar
shares were down 2-1/2 at 58-7/8. Citizens Bancorp soared 14-5/8 to
46-7/8.</p>\n</text>\r\n<copyright>(c) Reuters Limited',
'55964newsML': '<?xml version="1.0" encoding="iso-8859-1"
?>\r\n<newsitem itemid="55964" id="root" date="1996-09-16"
xml:lang="en">\r\n<title>USA: Nebraska cattle sales thin at
$114/dressed-feedlot.</title>\r\n'
}
}
我认为MongoDB会很合适,但看起来它要求键和值都必须是 Unicode,并且由于我从上面获取文件名,namelist()
因此ZipFile
不能保证是 Unicode。
您如何建议我将这本字典序列化到数据库中?