File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 11import abc
22import datetime
3- from io import BytesIO , IOBase
3+ from io import BytesIO , BufferedIOBase , RawIOBase
44import os
55from textwrap import fill
6+ from typing import Union
67
78from pandas ._config import config
89
@@ -778,7 +779,22 @@ def close(self):
778779 return self .save ()
779780
780781
781- def _is_ods_stream (stream ):
782+ def _is_ods_stream (stream : Union [BufferedIOBase , RawIOBase ]) -> bool :
783+ """
784+ Check if the stream is an OpenDocument Spreadsheet (.ods) file
785+
786+ It uses magic values inside the stream
787+
788+ Parameters
789+ ----------
790+ stream : Union[BufferedIOBase, RawIOBase]
791+ IO stream with data which might be an ODS file
792+
793+ Returns
794+ -------
795+ is_ods : bool
796+ Boolean indication that this is indeed an ODS file or not
797+ """
782798 stream .seek (0 )
783799 is_ods = False
784800 if stream .read (4 ) == b"PK\003 \004 " :
@@ -829,7 +845,7 @@ class ExcelFile:
829845 def __init__ (self , path_or_buffer , engine = None ):
830846 if engine is None :
831847 engine = "xlrd"
832- if isinstance (path_or_buffer , IOBase ):
848+ if isinstance (path_or_buffer , ( BufferedIOBase , RawIOBase ) ):
833849 if _is_ods_stream (path_or_buffer ):
834850 engine = "odf"
835851 else :
You can’t perform that action at this time.
0 commit comments