-
Notifications
You must be signed in to change notification settings - Fork 0
/
19_07_2017.py
84 lines (75 loc) · 2.83 KB
/
19_07_2017.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 19 10:58:57 2017
@author: mchiquier
"""
import pandas as pd
contacts = pd.read_excel("Q:\Analytics\Proyectos\publications\data\linkedin\ContactosEscuela.xlsx", sheetname=0)
thestudents_empresa = contacts.iloc[5:,9].tolist()
thestudents_lastname = contacts.iloc[5:,6].tolist()
thestudents_firstname = contacts.iloc[5:,5].tolist()
totalname = zip(thestudents_firstname, thestudents_lastname)
totalnamefinal = []
import pickle
#making one total name out of first and last name, this is the lsit from it
#create a one thing of first and last name
for names in totalname:
first = names[0]
second = names[1]
finalname = []
if not isinstance(second, int):
if first == first :
finalname = first
if second == second :
finalname = finalname + ' ' + second
totalnamefinal.append(finalname)
with open('lista_nombres', "r") as fp:
nombres= pickle.load(fp)
import codecs
from unidecode import unidecode
nombresupdate = []
for name_afi in nombres:
try:
name_afi = codecs.decode(name_afi, "utf-8")
name_afi = unidecode(name_afi)
nombresupdate.append(name_afi)
except:
try:
name_afi = codecs.encode(name_afi, "utf-8")
name_afi = unidecode(name_afi)
nombresupdate.append(name_afi)
except:
try:
name_afi = codecs.decode(name_afi, "utf-8")
name_afi = codecs.encode(name_afi, "utf-8")
name_afi = unidecode(name_afi)
nombresupdate.append(name_afi)
except:
try:
name_afi = codecs.encode(name_afi, "utf-8")
name_afi = codecs.decode(name_afi, "utf-8")
name_afi = unidecode(name_afi)
nombresupdate.append(name_afi)
except:
name_afi = name_afi
nombresupdate.append(name_afi)
for totalname in totalnamefinal:
try:
totalname = codecs.decode(totalname, "utf-8")
totalname = codecs.encode(totalname, "utf-8")
totalname = unidecode(totalname)
except:
try:
totalname = codecs.encode(totalname, "utf-8")
totalname = codecs.decode(totalname, "utf-8")
totalname = unidecode(totalname)
except:
totalname = totalname
nombres1 = map(lambda x : x.lower(), nombres)
totalnamefinal1 = map(lambda x : x.lower(), totalnamefinal)
from collections import defaultdict
nombre_to_empresa = defaultdict(list)
for every in nombres :
if every in totalnamefinal :
our_index = totalnamefinal.index['every']
nombre_to_empresa[every] = thestudents_empresa[our_index]