I have been working with excel documents lately, and having difficulty grasping "tables". I think some of the confusion stems from the fact that some online resources refer to an array of values in a worksheet as a table, whereas I am interested in dealing with a table object ("insert table" in excel).
From a previous question, I got the sense that "tables" are recognizable by openpyxl which appeared to be able to read one in and manipulate it as one would a csv etc. I am however encountering an error upon loading the worksheet as a variable in my script:
VBS_Metrics_Report_dir = "path to .xlsx file"
VBS_Metrics_Report = openpyxl.load_workbook(os.path.join(VBS_Metrics_Report_dir, "VBS_Metrics_Report.xlsx"))
VBS_Membership_ws = VBS_Metrics_Report['Membership']
VBS_Membership_table = VBS_Membership_ws.tables['Membership']
---> 192 VBS_Metrics_Report = openpyxl.load_workbook(os.path.join(VBS_Metrics_Report_dir, "VBS_Metrics_Report.xlsx"))
ValueError: Table with name Membership already exists
First, I am confused as the line in which the error is said to be does not even attempt to access the table nor the sheet named "Membership" yet, that occurs in the following lines.
Second, where does this error claim the table to already exist? considering that the error occurs even after restarting the python kernel, it can't be that it already exists as a variable in my workspace. Even if it did, I should be able to overwrite a variable no?
If instead the problem is that the table already exists in the workbook I am trying to access, then yes, of course it already exists, that is why I am trying to access it. In order to make use of the data that I know it contains. In this case I must be misunderstanding the usage of the load_workbook function.
I realize this question has essentially been asked here, but it has not really been answered and I though I would add some thoughts.
If anyone can help me solve this problem OR has insight as to how handling excel "Tables" works to give me a better understanding, please let me know. It would be hugely appreciated!
Thanks.