Search code examples
pythonfilexlrd

python xlrd check if file is already open


Trying to determine if a certain excel file is already open. I have a script that opens up a template excel file and writes data to the file and then saves it as a specific formatted name. Now if the person runs the script again and forgets to close out of the excel file I get errors that stop the program saying cant save the file as it is already open. Is there a way to check if, not only a program is open (excel) but a specific file? That way I can prompt the user to either close the file or save it as another filename.


Solution

  • If the processing time of the input is really small you do not need to detect this before processing the file. You can easily catch the error that you describe with "I get errors that stop the program saying cant save the file as it is already open" and provide a meaningful error message to the user.