2つのフィールド(id、url)のみを含む非常に大きなCSVファイルがあります。Pythonを使用してURLフィールドのインデックスを作成したいのですが、WhooshやPyluceneなどのツールがあることを知っています。しかし、例を機能させることができません。誰かがこれを手伝ってくれますか?
1654 次
2 に答える
1
PyLucene is very easy to work with, but as you haven't posted your example i am not sure what problem you are facing.
Alternatively when you have only key:value type of data, may be better than Pylucene would be DB like Berkeley DB(python bindings pybsddb). It will work like python dictionary and should be more or as fast as lucene, you can try that.
于 2010-04-17T04:42:52.197 に答える
0
file.csvの内容:
a,b
d,f
g,h
すべてを1つの巨大な辞書にロードするPythonスクリプト:
#Python 3.1
giant_dict = {id.strip(): url.strip() for id, url in (line.split(',') for line in open('file.csv', 'r'))}
print(giant_dict)
{'a': 'b', 'd': 'f', 'g': 'h'}
于 2010-04-16T23:34:19.073 に答える