2

This is my first post. I want to read excel file in python 3 which is updating every second. this is what i have tried

>>> import pandas as pd
>>> import xlrd
>>> parsed=pd.read_excel(open("PATH TO FILE","rb"),sheet_name="Default")
>>> parsed

i always get same old data. Old Data

But not updated data, Updated Data

even if i call last statement again. Please help

I tried to open excel with read_excel after update of excel file but still getting old results.

I tried few things more and found that i was not able to get right result because excel was updated by server but not saved after each return. When i forcefully saved excel during updates. I got updated results. But how can i save automatically excel with each update?

  • 1
    This asnwer might be useful as it also deals with a similar topic https://stackoverflow.com/questions/5419888/reading-from-a-frequently-updated-file – S Raghav Mar 19 '18 at 07:32
  • Well your last statment is printing same data that you have fetched before in your 2nd last statement call your 2nd last statement after updating data then call the last statment – Abdullah Ahmed Ghaznavi Mar 19 '18 at 07:34
  • 1
    @raghav710 how to open excel file like that? aren't we supposed to use pandas for this or xlrd module –  Mar 19 '18 at 07:35
  • @AbdullahAhmedGhaznavi i tried 3rd statement for opening file in freash way but again i got same results –  Mar 19 '18 at 07:37
  • @YugKaswan waiting for the file to change and then reading in the fresh data should be a good approach. As suggested here: https://stackoverflow.com/questions/47709010/read-and-plot-real-time-live-self-updating-csv-file – S Raghav Mar 19 '18 at 07:41
  • You'll have to close and open the file each time you want to get updated results. – Burhan Khalid Mar 19 '18 at 07:58
  • @raghav710 file doesn't save automatically until i explicitly save it. –  Mar 19 '18 at 08:49
  • @YugKaswan can you please clarify that point. Isn't the data written by some program into the excel file and automatically saved? – S Raghav Mar 19 '18 at 08:54
  • @raghav710 data is written by a server but not saved automatically in excel.... is there any way in python to save excel file written by server –  Mar 19 '18 at 12:37
  • @YugKaswan where does the server write the data? is it some file? – S Raghav Mar 19 '18 at 17:19
  • @raghav710 server writes data in a excel file every second but doesn't save it, to save file i have to explicitly save it. –  Mar 22 '18 at 14:27
  • Excel is being updated every second? I find that hard to believe. Whatever data source is being fed into Excel, should probably be fed directly into Python, if that's your end game. – ASH May 23 '18 at 18:03

0 Answers0