-
Notifications
You must be signed in to change notification settings - Fork 0
/
excel_headers.py
77 lines (53 loc) · 1.66 KB
/
excel_headers.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
from pandas.io.clipboard import clipboard_get
import subprocess
from datetime import date, datetime
# from pynput.keyboard import Key, Controller
d = datetime.now()
date = d.strftime('%Y%m%d-%H%M%S')
def write_to_clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))
text = clipboard_get()
output = str()
print()
list_headers = text.split('\t')
count = -1
print_string = 'print('
for header in list_headers:
count += 1
header = str(header.lower())
if '/' in header:
header = header.replace('/', '_')
if 'first' in header:
header = 'first'
if 'last' in header:
if not 'activity' in header and not 'seen' in header:
header = 'last'
if 'title' in header:
header = 'title'
# if 'phone' in header:
# header = 'phone'
header = header.replace(' ', '_')
x = header
# if any(ele in header.lower() for ele in ['date', 'found', 'twitter', 'linkedin', 'country']):
# header = f"{header} = row[{count}].value"
# else:
# header = f"{header} = row[{count}].value.strip()"
header = f"{header} = row[{count}].value"
if output == '':
output = f"{header}"
else:
output = f"{output}\n{header}"
print_string = f"{print_string}{x}, "
print_string = f"{print_string})"
output = f"{output}\n\n{print_string}"
write_to_clipboard(output)
# keyb = Controller()
# with keyb.pressed(Key.cmd):
# keyb.press('f')
# keyb.release('f')
# print(f'\nOutput copied to clipboard:\n\n{output}\n')
print(f'\nOutput copied to clipboard')
print()
###