We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88a946b commit 9895affCopy full SHA for 9895aff
1 file changed
Work/follow.py
@@ -0,0 +1,18 @@
1
+# follow.py
2
+import os
3
+import time
4
+
5
+f = open("Data/stocklog.csv")
6
+f.seek(0, os.SEEK_END) # Move file pointer 0 bytes from end of file
7
8
+while True:
9
+ line = f.readline()
10
+ if line == "":
11
+ time.sleep(0.1) # Sleep briefly and retry
12
+ continue
13
+ fields = line.split(",")
14
+ name = fields[0].strip('"')
15
+ price = float(fields[1])
16
+ change = float(fields[4])
17
+ if change < 0:
18
+ print(f"{name:>10s} {price:>10.2f} {change:>10.2f}")
0 commit comments