Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import os, sys, pdb, csv
- import pymongo
- from pymongo import Connection
- from collections import namedtuple
- connection = Connection("localhost",27017)
- db = connection.nextel
- def read_contacts(arq):
- cont = namedtuple("Contato","name number type id")
- contatos = {}
- for line in map(cont._make,csv.reader(open(arq, "rb")))[1:]:
- if not line.name in contatos.keys():
- contatos[line.name] = {}
- contatos[line.name][line.type] = line.number
- if __name__ == "__main__":
- if sys.argv[1] != "":
- read_contacts(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement