I'm using python, and want to read a file that is being written with new data. However everytime I read the last line (waiting for the new line to be written in), it goes wrong. The new line isn't the same length or format as the old ones.. Is there a way to wait until a new \n
appears, then read the line.
here is my code:
def get_mkt_data(mkt_data_fp):
fields = mkt_data_fp.readline()
fields = fields.split(",") # here is the columns
while True:
where = mkt_data_fp.tell()
line = mkt_data_dp.readline().split(",")
if len(line) == len(fields):
row = dict(zip(fields, line))
yield row
else:
mkt_data_dp.seek(where)
time.sleep(1)