klsadakse
This commit is contained in:
parent
6cc9b02069
commit
ff90021f38
16
src/main.py
16
src/main.py
@ -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__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user