Generic access to DBM-style databases : DBM : Database PYTHON examples


PYTHON examples » Database » DBM »

 

Generic access to DBM-style databases


Generic access to DBM-style databases


import fileinput, os, anydbm
wordPos = {}
sep = os.pathsep
for line in fileinput.input():
    pos = '%s%s%s'%(fileinput.filename(), sep, fileinput.filelineno())
    for word in line.split():
        wordPos.setdefault(word,[]).append(pos)

dbmOut = anydbm.open('indexfile','n')
sep2 = sep * 2
for word in wordPos:
    dbmOut[word= sep2.join(wordPos[word])
dbmOut.close()

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Database
» DBM