klsadakse

This commit is contained in:
Boyan 2024-06-04 16:24:32 +02:00
parent 6cc9b02069
commit ff90021f38
Signed by: boyan_k
GPG Key ID: 620E9CC7A57EAAA5

View File

@ -26,21 +26,10 @@ def get_json(url:str) -> list[dict]:
raw = raw.decode('utf-8') raw = raw.decode('utf-8')
# turn it into json # turn it into json
reader = csv.DictReader(raw) arr = reader_to_json(csv.DictReader(raw.splitlines()))
arr = reader_to_json(reader)
return arr return arr
# DEBUG function. Loads a local file
def local_file(path:str) -> list[dict]:
with open(path, "r") as i:
reader:list = reader_to_json(csv.DictReader(i))
with open("out.json", "w") as o:
o.write(dumps(reader, indent=2))
return reader
# Gets file from the server # Gets file from the server
def get_file(entries:int) -> dict: def get_file(entries:int) -> dict:
url = f"{ROOT}/Portal/Portal.mwsl?PriNav=DataLog&RecentCount={entries}" url = f"{ROOT}/Portal/Portal.mwsl?PriNav=DataLog&RecentCount={entries}"
@ -68,9 +57,6 @@ def save_file(json:list[dict], filename:str) -> None:
def main(): def main():
file = get_file(10) file = get_file(10)
# DEBUG: local test file
#file = local_file("test.csv")
# Save file
save_file(file, "out.json") save_file(file, "out.json")
if __name__ == "__main__": if __name__ == "__main__":