
    .i                        d dl mZ d dlmZ d dlZd dlmZ d dlZd dl	m
Z
 d dlmZ erd dlmZ d dlmZmZ  G d	 d
ed         Zy)    )annotations)timeN)TYPE_CHECKING)import_optional_dependency)BaseExcelReaderBook)ScalarStorageOptionsc                  x     e Zd Z	 	 d	 	 	 	 	 d	 fdZed
d       ZddZed        Zd Zd Z		 d	 	 	 ddZ
 xZS )
XlrdReaderc                H    d}t        d|       t        | 	  |||       y)a  
        Reader using xlrd engine.

        Parameters
        ----------
        filepath_or_buffer : str, path object or Workbook
            Object to be parsed.
        storage_options : dict, optional
            Extra options that make sense for a particular storage connection,
            e.g. host, port, username, password, etc. For HTTP(S) URLs the
            key-value pairs are forwarded to ``urllib.request.Request`` as
            header options. For other URLs (e.g. starting with "s3://", and
            "gcs://") the key-value pairs are forwarded to ``fsspec.open``.
            Please see ``fsspec`` and ``urllib`` for more details, and for more
            examples on storage options refer `here <https://pandas.pydata.org/
            pandas-docs/stable/user_guide/io.html?
            highlight=storage_options#reading-writing-remote-files>`__.
        engine_kwargs : dict, optional
            Arbitrary keyword arguments passed to excel engine.
        z+Install xlrd >= 2.0.1 for xls Excel supportxlrd)extra)storage_optionsengine_kwargsN)r   super__init__)selffilepath_or_bufferr   r   err_msg	__class__s        S/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/io/excel/_xlrd.pyr   zXlrdReader.__init__   s0    4 @"69+' 	 	
    c                    ddl m} |S )Nr   r   )r   r	   )r   r	   s     r   _workbook_classzXlrdReader._workbook_class9   s
    r   c                l    ddl m} t        |d      r|j                         } |dd|i|S  ||fi |S )Nr   )open_workbookreadfile_contents )r   r   hasattrr   )r   r   r   r   datas        r   load_workbookzXlrdReader.load_workbook?   sB    &%v.%**,D EtE}EE !3E}EEr   c                6    | j                   j                         S N)booksheet_names)r   s    r   r(   zXlrdReader.sheet_namesH   s    yy$$&&r   c                Z    | j                  |       | j                  j                  |      S r&   )raise_if_bad_sheet_by_namer'   sheet_by_name)r   names     r   get_sheet_by_namezXlrdReader.get_sheet_by_nameL   s%    ''-yy&&t,,r   c                Z    | j                  |       | j                  j                  |      S r&   )raise_if_bad_sheet_by_indexr'   sheet_by_index)r   indexs     r   get_sheet_by_indexzXlrdReader.get_sheet_by_indexP   s%    ((/yy''..r   c                z  	
 ddl mm	m
mm | j                  j                  	
fd}|j                  }|t        ||      }t        |      D cg c]H  }t        |j                  |      |j                  |      d      D cg c]  \  }} |||       c}}J c}}}S c c}}w c c}}}w )Nr   )XL_CELL_BOOLEANXL_CELL_DATEXL_CELL_ERRORXL_CELL_NUMBERxldatec                   |k(  rl	 	j                  |       } | j                         dd }s|dk(  sr;|dk(  r6t        | j                  | j
                  | j                  | j                        } | S |k(  rt        j                  } | S |k(  rt        |       } | S |k(  r't        j                  |       rt        |       }|| k(  r|} | S # t        $ r | cY S w xY w)z\
            converts the contents of the cell into a pandas appropriate object
            r      )ik        )ip     r=   )xldate_as_datetimeOverflowError	timetupler   hourminutesecondmicrosecondnpnanboolmathisfiniteint)
cell_contentscell_typyearvalr4   r5   r6   r7   	epoch1904r8   s
       r   _parse_cellz.XlrdReader.get_sheet_data.<locals>._parse_cella   s    <')$*$=$=mY$WM &//11Q7!dn&<$,"6$(%**%,,%,,%11	%M& !  ]* " !  _, $] 3 !  ^+ ==/m,Cm+(+  ; % )(()s   C
 
CCT)strict)r   r4   r5   r6   r7   r8   r'   datemodenrowsminrangezip
row_values	row_types)r   sheetfile_rows_neededrP   rS   ivaluetypr4   r5   r6   r7   rO   r8   s           @@@@@@r   get_sheet_datazXlrdReader.get_sheet_dataT   s    	
 	
 II&&	%	! %	!N '/0E 5\
 
 	 #&$$Q');D#E3 E3'
 	

s   4B6B0%B60B6)NN)r   zStorageOptions | Noner   zdict | NonereturnNone)r_   z
type[Book])r_   r	   r&   )rZ   z
int | Noner_   zlist[list[Scalar]])__name__
__module____qualname__r   propertyr   r$   r(   r-   r2   r^   __classcell__)r   s   @r   r   r      s     26%)	 
 / 
 #	 

 
 
D  
F ' '-/
 59?
'1?
	?
r   r   r	   )
__future__r   datetimer   rH   typingr   numpyrE   pandas.compat._optionalr   pandas.io.excel._baser   r   r	   pandas._typingr
   r   r   r!   r   r   <module>rm      s8    "      > 1}
( }
r   