-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathok.py
27 lines (24 loc) · 819 Bytes
/
ok.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import plotly.express as px
import csv
from pathlib import Path
while True:
print("Copy-paste CSV file address to visualize it. Type 'exit' to exit.")
while True:
fuck = input(" : ")
if len(fuck):
break
fuckLower = fuck.lower()
if fuckLower == "exit":
exit(0)
else:
if not fuckLower.endswith(".csv"):
fuck += ".csv"
try:
with open(fuck) as file:
rows = [r for r in csv.DictReader(file)]
fig = px.line(x=[int(r['time']) for r in rows], y=[int(r['value']) for r in rows], title=Path(fuck).stem)
fig.show()
except FileNotFoundError:
print("Cannot locate file at '%s'" % fuck)
except OSError:
print("Cannot access file at '%s'" % fuck)