-
Notifications
You must be signed in to change notification settings - Fork 0
/
d-terr.py
159 lines (124 loc) · 4.74 KB
/
d-terr.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# by d4v.id
from tqdm import tqdm
import sys
from colorama import Fore,Style
import os
bl = Fore.BLUE
wh = Fore.WHITE
gr = Fore.GREEN
red = Fore.RED
res = Style.RESET_ALL
yl = Fore.YELLOW
def ket_file(ket):
words = 0
with open(ket, "r") as kata_file:
for line in kata_file:
num_kata = line.split(";"or","or":"or".")
words += len(num_kata)
return str(words)
def split_line():
os.system("cls")
print(f"{gr}\n//{res}{yl} D-TERR by d4v.id{res}")
print(f"{gr}//{res}{yl} Splitter Lines {res}")
#File Input
print(f"{red}\n[{res}?{red}]{res} Enter Filename (.txt):")
nama = str(input(f"{gr}>>{res} "))
nama_file = open(nama, "r")
read_file = nama_file.read()
print("\nFile: {}".format(nama))
print("Lines: {}".format(all_line(nama)))
lines = read_file.split()
print(f"{red}[{res}#{red}]{res} Splitter Lines({yl}Ex: 34000 - end{res})")
print(f"{red}[{res}?{red}]{res} Enter Number To Split ({yl}Ex: 34000{res}):")
num = int(input(f"{gr}>>{res} "))
print(f"{red}\n[{res}?{red}]{res} Enter Output Filename (.txt):")
outFile = str(input(f"{gr}>>{res} "))
print("\n\nProcessing: {} - {} lines".format(int(all_line(nama)), num))
print("Result: {} copyied".format(int(all_line(nama)) - num))
if int(all_line(nama)) - num < 0:
print(f"{red}Failed Input{res}")
exit()
num_line = lines[(num-1):]
with open(outFile,"w") as nama_file:
for all_in in tqdm(num_line):
nama_file.write("{}\n".format(all_in))
print(f"{gr} SUCCESS SAVE {res}[{gr}{outFile}{res}]")
def all_line(file_line):
baris = 0
with open(file_line, "r") as file:
for line in file:
baris += 1
line = baris
return str(line)
def typeSplit(sign):
if sign == 1:
split = ":"
elif sign == 2:
split = ","
elif sign == 3:
split = ";"
elif sign == 4:
split = "|"
elif sign == 5:
split = "#"
else:
print(f"{red}Wrong input..")
return str(split)
def name_file():
print(f"{red}\n[{res}?{red}]{res} Enter Filename (.txt) >")
nama = str(input(f"{gr}>>{res} "))
print("File: {}\nLine: {}\nWords: {}".format(nama, all_line(nama), ket_file(nama)))
def split_text():
os.system("cls")
print(f"{gr}\n//{res}{yl} D-TERR by d4v.id{res}")
print(f"{gr}//{res}{yl} Splitter Text {gr}--> {yl}: , ; | #{res}")
# File Input
print(f"{red}\n[{res}?{red}]{res} Enter Filename (.txt) >")
nama = str(input(f"{gr}>>{res} "))
nama_file = open(nama, "r")
print(f"{red}\n[{res}#{red}]{res} List Splitter{yl} (; : , | #) {res}")
print(f"{red}[{res}#{red}]{res} Ex: [ admin{yl};{res}pa213ss{yl};{res}[email protected] ]")
# Type Input
print(f"{red}\n[{res}?{red}]{res} Split Type\t1.) {yl}:{res} 2.) {yl},{res} 3.) {yl};{res} 4.) {yl}|{res} 5.) {yl}#{res}")
numType = int(input(f"{gr}>>{res} "))
# Select Input
print(f"{red}\n[{res}#{red}]{res} Ex: [ admin{yl};{res}pa213ss{yl};{res}[email protected] ]")
print(f"{red}[{res}?{red}]{res} [ 0 {yl};{res} 1 {yl};{res} 2 ] \nChoose number (ex: 0): ")
num = int(input(f"{gr}>>{res} "))
# Output Input
print(f"{red}\n[{res}?{red}]{res} Enter Output Filename (.txt) >")
outFile = str(input(f"{gr}>>{res} "))
inputType = typeSplit(numType)
read_file = nama_file.readlines()
with open(outFile, "w") as nama_file:
for line in tqdm(read_file):
if inputType in line:
action = line.split(inputType)
input_action = action
nama_file.write("{}\n".format(input_action[num]))
else:
pass
print(f"{gr} SUCCESS SAVE {res}[{gr}{outFile}{res}]")
# MAIN
os.system("cls")
print(f"{gr}\n//{res}{yl} D-TERR by d4v.id{res}")
type_tools = [f"File Checker", "Splitter Text(: , ; | #)", "Splitter Lines"]
print(f"{gr}//{res}{yl} Multiple For Splitter{res}")
try:
print(f"{red}\n[{res}?{red}]{res} Choose Methode: ")
print("\t(1) {}\t(2) {}\t(3). {}".format(type_tools[0], type_tools[1], type_tools[2]))
put_number =int(input(f"{gr}\t>>{res} "))
if put_number == 1:
name_file()
elif put_number == 2:
split_text()
elif put_number == 3:
split_line()
except ValueError:
print(f"{red}\nFailed Input..{res}")
except FileNotFoundError:
print(f"{red}\nFile Notfound..{res}")
except IndexError:
print(f"{red}\nFailed Split Type / Input..{res}")
except KeyboardInterrupt:
print(f"{red}\nExiting...{res}")