I would like to read an excel-file with python. My first attempt is about reading the worksheets, the second attempt would then be about reading cells. Unfortunately, I am stuck with the first step.
The code:
import openpyxl
wb = openpyxl.load_workbook ("C:\\Users\\Alex\\Documents\\Python\\Übung\\example1.xlxs")
wb.get_sheet_by_name()
the following messages appear:
FileNotFoundError Traceback (most recent call last)
<ipython-input-26-7b234f637152> in <module>()
1 import openpyxl
----> 2 wb = openpyxl.load_workbook("\\Users\\Alex\\Documents\\Python\\Übung\\example1.xlxs")
3 wb.get_sheet_by_name()
~\Anaconda3\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, guess_types, keep_links)
169
170 """
--> 171 archive = _validate_archive(filename)
172 read_only = read_only
173
~\Anaconda3\lib\site-packages\openpyxl\reader\excel.py in _validate_archive(filename)
116
117 try:
--> 118 archive = ZipFile(filename, 'r', ZIP_DEFLATED)
119 except BadZipfile:
120 f = repair_central_directory(filename, is_file_like)
~\Anaconda3\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64)
1088 while True:
1089 try:
-> 1090 self.fp = io.open(file, filemode)
1091 except OSError:
1092 if filemode in modeDict:
FileNotFoundError: [Errno 2] No such file or directory: '\\Users\\Alex\\Documents\\Python\\Übung\\example1.xlxs'
I referenced the file using an absolute path and it exits, but why do I get an error that the file is not found nevertheless? And what about the rest of the error messages, I have no clue what they mean or whether this can be dismissed. Thanks for help.