import os, os.path, sys, re, csv, string
def csv2db():
data = csv.reader(open('gene2go.txt', 'rb'), delimiter='\t')
data.next()
import rethinkdb as r
r.connect('localhost', 28015).repl()
r.db('test').table_create('gene2go').run()
gene2go = r.db('test').table('gene2go')
for row in data:
gene2go.insert({
'tax_id': row[0],
'GeneID': row[1],
'GO_ID': row[2],
'Evidence': row[3],
'Qualifier': row[4],
'GO_term': row[5],
'PubMed': row[6],
'Category': row[7]
}).run(durability="soft", noreply=True)
def main():
csv2db()
if __name__ == "__main__":
main()