Finished Parser
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
#
|
#
|
||||||
# @Script: CutieParser.py
|
# @Script: CutieParser.py
|
||||||
# @Date Created: 10 Apr, 2024
|
# @Date Created: 10 Apr, 2024
|
||||||
# @Last Modified: 23 Apr, 2024
|
# @Last Modified: 25 Apr, 2024
|
||||||
# @Last Modified by: Cutieguwu | Olivia Brooks
|
# @Last Modified by: JellieJayde | Jayde Paquette
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -24,29 +24,26 @@ from os import path
|
|||||||
|
|
||||||
execDir = path.dirname(__file__)
|
execDir = path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
def parse(dataReference, dataEncoded):
|
|
||||||
return order(dataReference), order(dataEncoded)
|
|
||||||
|
|
||||||
def order(file):
|
def order(file):
|
||||||
|
|
||||||
dataLanguage = []
|
dataLanguage = []
|
||||||
amount = []
|
amount = []
|
||||||
index = 0
|
index = 0
|
||||||
|
sortedString = ""
|
||||||
|
|
||||||
with open(execDir + file, "r") as f:
|
with open(execDir + file, "r") as f:
|
||||||
while True:
|
while True:
|
||||||
fileChar = f.read(1).strip()
|
fileChar = f.read(1).strip()
|
||||||
|
|
||||||
if fileChar.isalpha():
|
if fileChar.isalpha():
|
||||||
if fileChar.lower() not in dataLanguage:
|
if fileChar.upper() not in dataLanguage:
|
||||||
dataLanguage.append(fileChar.lower())
|
dataLanguage.append(fileChar.upper())
|
||||||
amount.append(1)
|
amount.append(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
index = 0
|
index = 0
|
||||||
while True:
|
while True:
|
||||||
if dataLanguage[index] == fileChar.lower():
|
if dataLanguage[index] == fileChar.upper():
|
||||||
amount[index] = amount[index] + 1
|
amount[index] = amount[index] + 1
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -76,7 +73,11 @@ def order(file):
|
|||||||
if index == len(amount):
|
if index == len(amount):
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
return dataLanguage, amount
|
for i in dataLanguage:
|
||||||
|
sortedString = sortedString + i
|
||||||
|
|
||||||
|
|
||||||
|
return sortedString
|
||||||
|
|
||||||
print (order("\\dataReference.txt"), "\n")
|
print (order("\\dataReference.txt"), "\n")
|
||||||
print (order("\\dataEncoded19.ENC"), "\n")
|
print (order("\\dataEncoded19.ENC"), "\n")
|
||||||
Reference in New Issue
Block a user