mirror of
https://github.com/minoplhy/filters-maker.git
synced 2024-12-22 10:08:11 +00:00
duplicat : init
This commit is contained in:
parent
dff9be3c3c
commit
353570725a
32
duplicat.py
Normal file
32
duplicat.py
Normal file
@ -0,0 +1,32 @@
|
||||
def add_file(input, output):
|
||||
with open(input, 'r') as f:
|
||||
lines = f.read().split()
|
||||
with open(output, 'a') as f:
|
||||
for line in lines:
|
||||
f.write('\n'.join([line + '\n']))
|
||||
f.close()
|
||||
print('Getting rid of duplicated line')
|
||||
with open(output, 'r') as f:
|
||||
lines = set(f.readlines())
|
||||
with open(output, 'w') as f:
|
||||
f.writelines(set(lines))
|
||||
f.close()
|
||||
|
||||
def check_n_kill_dupes(duperuleset, input):
|
||||
with open(duperuleset, 'r') as s:
|
||||
ruleset = s.read().split()
|
||||
with open(input, 'r') as f:
|
||||
lines = f.read().split()
|
||||
with open(input, 'w') as f:
|
||||
for line in lines:
|
||||
if not line in ruleset:
|
||||
f.write('\n'.join([line + '\n']))
|
||||
f.close()
|
||||
# Remove Blank Line
|
||||
with open(input ,'r') as f:
|
||||
lines = f.read().split()
|
||||
with open(input ,'w') as f:
|
||||
for line in lines:
|
||||
if line.strip():
|
||||
f.write('\n'.join([line + '\n']))
|
||||
f.close()
|
Loading…
Reference in New Issue
Block a user