#!/usr/bin/python
# -*- coding: utf-8 -*-
import shelve,string,os
sourcefile = 'vortoj-ru-ca.txt'
dbfile = 'vortoj-ru-ca.sdb'
try:
os.remove(dbfile)
except:
print "File '%s' doesn't exist. Creating..." % dbfile
else:
print "File '%s' exist. Wipping..." % dbfile
dbase = shelve.open(dbfile)
# Read txt
file = open(sourcefile, 'r')
for line in file:
line = line.rstrip('\n')
words = string.split(line, '\t')
print "Adding:", words[0], '=>', words[2]
dbase[words[0]] = words[2]
file.close()
dbase.close()