1

I am fetching data from the exchange and storing it into an excel sheet & reading using python script, which is working fine.

But to get the latest values I need to read excel file every 1 sec.

So my question is there any way to get an event whenever any column updates on excel?

If yes can you give me some link and or some sample code?

If no is there any way to optimize the reading the excel file?

Here is the my python code to read the file:

import pandas as pd

excel_loc = "/Users/usr/Downloads/Sample.xls"
pd_excel = pd.read_excel(excel_loc)
print(pd_excel['id']

Thanks in advance.

szatmary
  • 29,969
  • 8
  • 44
  • 57
Vikas Kad
  • 1,013
  • 1
  • 18
  • 38
  • What do you mean by column update? any value in the column is changed? If so, you might be able to hash the file and if the hash has changed, then you know something in the file has changed. – john doe Oct 04 '19 at 15:36
  • @johndoe yes if any column value get changed – Vikas Kad Oct 04 '19 at 15:38
  • ***"fetching data from the exchange and storing it into an excel sheet"**: How do you do this? – stovfl Oct 04 '19 at 19:35
  • @stovfl I am using panda data-frame to fetch data and then storing into excel – Vikas Kad Oct 05 '19 at 08:35
  • @VRK: ***"using `pandas` to fetch data"***: Why do you have to ***"read excel file"*** again as you can hold the previous `df` in memory? Relevant [compare-pandas-dataframes](https://stackoverflow.com/questions/32770797/how-do-i-overload-eq-to-compare-pandas-dataframes-and-series) – stovfl Oct 05 '19 at 08:40
  • @stovfl there are some calculations are done on excel, which client don't want us to know :( – Vikas Kad Oct 05 '19 at 10:19
  • ***"calculations are done on excel"***: This is irrelevant to your Q: ***"detect column change"***, furthermore it makes detecting impossible as the calculations changes values all the time. You can do **1.** fetch `new_df` , **2.** compare `new_df.compare(last_df)`, **3.** `new_df.write_to_excel(..`. – stovfl Oct 05 '19 at 11:29
  • @stovfl yes finally achieved using this only, thanks for your help. – Vikas Kad Oct 05 '19 at 13:32

0 Answers0