0

I have a Microsoft Excel file on OneDrive. When my Python script saves anything to the file and the file is already open, OneDrive raises an error, telling me there is a sync issue.

If the file is closed(not in use by another user), everything works great.

Is there was a way to check if the file is currently in use by another person?

I forgot to mention that the file on onedrive is a shortcut to a sharepoint file.

mclogan
  • 35
  • 5
  • You can add password protection to open xls file so nobody can open or use or you can add size or legth system to check if anybody updating or adding something then file length will affect by increase or dectease data size – Ehsan Rahi Oct 02 '21 at 09:49
  • check this = > https://stackoverflow.com/questions/53778455/checking-if-other-users-are-editing-a-google-sheet – Singh Oct 02 '21 at 09:51
  • I forgot to mention that the file in omedrive is a shortcut to a sharepoint file. – mclogan Oct 08 '21 at 14:45

2 Answers2

0

In case you have sheet.xlsx and someone has opened it, you should see ~$sheet.xlsx file in the same directory.

-rw-r--r--@  1 szymon  szymon   9431 Oct  2 11:41 sheet.xlsx
-rw-r--r--@  1 szymon  szymon    165 Oct  2 11:45 ~$sheet.xlsx
Szymon Kocot
  • 128
  • 1
  • 9
0

Will it help you?

try:
    with open("file_name", "r") as file:
        print("File has opened for reading.")
except IOError:
    print("Error, The File is open.")