Repository: pandas-dev/pandas

Issue:
read_excel: sheet_name of non-existent sheet does not raise appropriate error for engine='odf'
#### Code Sample, a copy-pastable example if possible

```python
pandas.read_excel('mybook.ods', sheet_name='mysheet', engine='odf')

```
#### Problem description

If the sheet specified does not exist, an error is thrown:

```
---> 63         raise ValueError("sheet {name} not found".format(name))
     64 
     65     def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:

KeyError: 'name'


```

The problem is at https://github.com/pandas-dev/pandas/blob/master/pandas/io/excel/_odfreader.py#L63



#### Expected Output

It should raise a `ValueError` with text:
> "sheet mysheet not found"

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.3.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.0.0-20-generic
machine          : x86_64
processor        : x86_64
byteorder        : little
LC_ALL           : None
LANG             : en_GB.UTF-8
LOCALE           : en_GB.UTF-8

pandas           : 0.25.0
numpy            : 1.16.4
pytz             : 2019.1
dateutil         : 2.8.0
pip              : 19.1.1
setuptools       : 41.0.1
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : None
IPython          : 7.6.1
pandas_datareader: None
bs4              : None
bottleneck       : None
fastparquet      : None
gcsfs            : None
lxml.etree       : None
matplotlib       : 3.1.1
numexpr          : 2.6.9
odfpy            : None
openpyxl         : 2.6.2
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.3.0https://github.com/pandas-dev/pandas/blob/master/pandas/io/excel/_odfreader.py#L63
sqlalchemy       : None
tables           : 3.5.2
xarray           : None
xlrd             : 1.2.0
xlwt             : None
xlsxwriter       : None


</details>



Discussion:

Resolving patch:
diff --git a/pandas/io/excel/_odfreader.py b/pandas/io/excel/_odfreader.py
--- a/pandas/io/excel/_odfreader.py
+++ b/pandas/io/excel/_odfreader.py
@@ -60,7 +60,7 @@ def get_sheet_by_name(self, name: str):
             if table.getAttribute("name") == name:
                 return table
 
-        raise ValueError("sheet {name} not found".format(name))
+        raise ValueError("sheet {} not found".format(name))
 
     def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:
         """Parse an ODF Table into a list of lists


Test patch:
diff --git a/pandas/tests/io/excel/test_odf.py b/pandas/tests/io/excel/test_odf.py
--- a/pandas/tests/io/excel/test_odf.py
+++ b/pandas/tests/io/excel/test_odf.py
@@ -36,3 +36,11 @@ def test_read_writer_table():
     result = pd.read_excel("writertable.odt", "Table1", index_col=0)
 
     tm.assert_frame_equal(result, expected)
+
+
+def test_nonexistent_sheetname_raises(read_ext):
+    # GH-27676
+    # Specifying a non-existent sheet_name parameter should throw an error
+    # with the sheet name.
+    with pytest.raises(ValueError, match="sheet xyz not found"):
+        pd.read_excel("blank.ods", sheet_name="xyz")