Kaushik Sudra
Kaushik Sudra

Reputation: 11

How to parse from from streaming excel sheet to python pandas df?

I have an excel sheet with [.xls] format containing live streaming of stock data from a software. I want to read and process the data from the sheet in python after every 5 seconds.

Python is getting refreshed data only when i manually save the .xls file. It is not automatically getting new data points on running script after 1st time.

Any help?

Upvotes: 1

Views: 823

Answers (1)

Sushil
Sushil

Reputation: 5531

This should help you:

import threading
import pandas as pd

def main_task():
    threading.Timer(5.0, main_task).start() #Repeats the function main_task every 5 seconds
    df = pd.read_excel("filename.xls") #Reads the excel file
    
main_task() #Calls the function

This code will update your pandas DataFrame with the new values every 5 seconds.

Upvotes: 1

Related Questions