Skip to content
Snippets Groups Projects
Commit a35ec94f authored by Jacob Theisen's avatar Jacob Theisen
Browse files

lesgo

parent 08b6e655
No related branches found
No related tags found
No related merge requests found
...@@ -158,9 +158,9 @@ num_of_bytes = len(bytes) ...@@ -158,9 +158,9 @@ num_of_bytes = len(bytes)
with open('./trash/huffmann_test_file_comp', 'w') as file: with open('./trash/huffmann_test_file_comp', 'w') as file:
for i in rep_tree_arr: for i in rep_tree_arr:
file.write(f'{i.symb} {i.val}') file.write(f'{i.symb}{i.val}\n')
file.write(f'{rest}') file.write(f'{num_of_bytes} {rest} END TABLE \n')
file.write(f'{num_of_bytes}')
with open('./trash/huffmann_test_file_comp', 'ab') as file: with open('./trash/huffmann_test_file_comp', 'ab') as file:
for i in bytes: for i in bytes:
......
...@@ -19,6 +19,7 @@ def run_comp(): ...@@ -19,6 +19,7 @@ def run_comp():
k = 0 k = 0
while True: while True:
#finished #finished
print(index)
if index + increment >= len(text): if index + increment >= len(text):
diff_inc = index + increment - len(text) diff_inc = index + increment - len(text)
diff = increment - diff_inc diff = increment - diff_inc
...@@ -72,53 +73,12 @@ def run_comp(): ...@@ -72,53 +73,12 @@ def run_comp():
#run func and print result #run func and print result
a = run_comp() a = run_comp()
print(a)
with open('./compressed_text', 'w') as file: with open('./compressed_text', 'w') as file:
file.write('') file.write('')
#print(a) #print(a)
i = 0 i = 0
'''a = a.replace('å', 'a')
a = a.replace('ø', 'o')
a = a.replace('æ', 'e')'''
'''
while i < len(a):
if a[i] == '[':
b = i
c = 0
while True:
b +=1
if a[b] == ']':
break
if a[b] == ',':
c = b-1
with open('./compresed', 'ab') as file:
if c != 0:
int2 = int(a[c+2:b])
int1 = int(a[i+1:c+1])
if int1 < 0:
int1 = int1 & 0xff
if int2 < 0:
int2 = int2 & 0xff
file.write(int1.to_bytes(1,'little'))
file.write(int2.to_bytes(1,'little'))
else:
print(a[i+1:b])
int1 = int(a[i+1:b])
file.write(int1.to_bytes(1,'little'))
diff = b - i
i += diff +1
else:
with open('./compresed', 'a') as file:
if a[i] == 'å':
file.write('a')
else:
file.write(a[i])
i +=1
'''
extra_bytes_counter2 = 0 extra_bytes_counter2 = 0
togle_replace = False togle_replace = False
togle_append_clear_text = False togle_append_clear_text = False
...@@ -174,8 +134,3 @@ while True: ...@@ -174,8 +134,3 @@ while True:
i+=1 i+=1
#with open('./compressed_text', 'rb') as file:
# print(file.read())
\ No newline at end of file
No preview for this file type
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment