daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest May 19th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os, sys, pdb, csv
  4. import pymongo
  5.  
  6. from pymongo import Connection
  7. from collections import namedtuple
  8.  
  9. connection = Connection("localhost",27017)
  10. db = connection.nextel
  11.  
  12. def read_contacts(arq):
  13.     cont = namedtuple("Contato","name number type id")
  14.     contatos = {}
  15.     for line in map(cont._make,csv.reader(open(arq, "rb")))[1:]:
  16.         if not line.name in contatos.keys():
  17.             contatos[line.name] = {}
  18.         contatos[line.name][line.type] = line.number
  19.    
  20.  
  21. if __name__ == "__main__":
  22.     if sys.argv[1] != "":
  23.         read_contacts(sys.argv[1])
RAW Paste Data
Top