-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert-comma-list-unique.py
88 lines (83 loc) · 1.18 KB
/
convert-comma-list-unique.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
85
86
87
88
import subprocess
# Input list of strings with line breaks
input_string = """ZIB01USD
ZIB01USD
Z8131325
Z8131325
XFER
XFER
WT080912
WT080912
WT080612
WT080612
WT080612
WT080612
WT050212
WT050212
WMS
WMS
WL438449
WL438449
WIRE PRE
WIRE PRE
WIRE PRE
WIRE PRE
WIRE PRE
WIRE9102
WIRE9102
WIRE8.31
WIRE8.31
WIRE8152
WIRE8152
WIRE4262
WIRE4262
WIRE4222
WIRE4222
WIRE4132
WIRE4132
WIRE3422
WIRE3422
WIRE3132
WIRE3132
WIRE3112
WIRE3112
WIRE2.6.
WIRE2.6.
WIRE2112
WIRE2112
WIRE1722
WIRE1722
WIRE1230
WIRE1230
WIRE1229
WIRE1229
WIRE1229
WIRE1229
WIRE1223
WIRE1223
WIRE1223
WIRE1223
WIRE1222
WIRE1222
WIRE1216
WIRE1216
WIRE1216
WIRE1216
WIRE1215
WIRE1215
WIRE1214
WIRE1214
WIRE1213
WIRE1213
"""
# Remove duplicates and preserve order
unique_strings = list(dict.fromkeys(line.strip() for line in input_string.strip().splitlines()))
# Format the list as a comma-separated string with single quotes
formatted_list = [f"'{item}'" for item in unique_strings]
result = ", ".join(formatted_list)
# Function to copy to clipboard
def copy2clip(txt):
cmd = 'echo ' + txt.strip() + '| clip'
return subprocess.check_call(cmd, shell=True)
# Copy the formatted string to the clipboard
copy2clip(result)