(Oct-30-2020, 10:38 PM)Makada Wrote: But i want the output to overwrite previous data instead of appendOverwrite and append may mot be the right wording here,as you only print the output.
So can clean the screen
cls
(Window),then only show new data.Also nice to have a way to exit out of loop eg
KeyboardInterrupt
.So can write a refresh function.
import requests import time import schedule from time import sleep import sys import csv import io from os import system, name def refresh(): # Windows if name == 'nt': _ = system('cls') # Mac and linux(here, os.name is 'posix') else: _ = system('clear') starttime=time.time() def task(): with io.open('Mynew.csv') as f: reader = csv.reader(f, delimiter=',') for field in reader: a = (field[1]) print(a) while True: try: task() time.sleep(7 - time.time() % 3) refresh() except KeyboardInterrupt: sys.exit() else: refresh()As you also have
import schedule
schedule installed,then can it better to use it to do schedule than calculate with
time.time
and time.sleep
.