
    [6g                       d dl mZ d dlmZmZ 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Zd dlmZ d dlmZ d dlZd dlZd d	lmZ d d
lmZ d dlmc mZ d dlZd dlmZmZm Z m!Z!m"Z" d dl#m$Z% d dl&m'Z'm(Z(  e            rej)        j*        Z+g dZ, ej-        d ej.        d          g           ej-        d ej.        d          g           ej-        d ej.        d          g           ej-        d ej.        d                     ej-        d ej.        d                     ej-        d ej.        d                    gZ/d-dZ0d Z1 ej2        d e/D             e3          d             Z4ej2        d             Z5ej2        d             Z6ej2        d              Z7d.d#Z8d/d'Z9d( Z: G d) d*          Z; G d+ d,          Z<dS )0    )annotations)datetimetime)partial)BytesION)Path)URLError)
BadZipFile)using_pyarrow_string_dtype)is_platform_windows)	DataFrameIndex
MultiIndexSeriesread_csv)ArrowStringArrayStringArray).xls.xlsx.xlsm.xlsb.odsxlrdmarksopenpyxlpyxlsbodfcalaminepython_calamineread_extstrreturnboolc                    | j         d         } | dk    r|dk    rdS | dk    r|dk    rdS |dk    r| dvrdS | dk    r|d	k    rdS |d	k    r| d
vrdS | dk    r|dk    rdS dS )zm
    Filter out invalid (engine, ext) pairs instead of skipping, as that
    produces 500+ pytest.skips.
    r   r   r   Fr   r   >   r   r   r   r   >   r   r   r   T)values)enginer!   s     a/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/pandas/tests/io/excel/test_readers.py_is_valid_engine_ext_pairr)   F   s    
 ]1FF 2 2u8v--u6f,???uh'11u7v-CCCuH..u4    c                R    | j         |fz   }t          j        || j                  }|S )z
    engine gives us a pytest.param object with some marks, read_ext is just
    a string.  We need to generate a new pytest.param inheriting the marks.
    r   )r&   pytestparamr   )r'   r!   r&   	new_params       r(   _transfer_marksr/   [   s.    
 ]h[(FV6<888Ir*   c                b    g | ],}t           D ]"}t          ||          t          ||          #-S  )read_ext_paramsr)   r/   ).0engexts      r(   
<listcomp>r6   f   sY       "  $S#..	S!!   r*   )paramsidsc                    | j         S )zS
    Fixture for Excel reader engine and read_ext, only including valid pairs.
    )r-   )requests    r(   engine_and_read_extr;   e   s     =r*   c                    | \  }}|S Nr1   r;   r'   r!   s      r(   r'   r'   u   s    *FHMr*   c                    | \  }}|S r=   r1   r>   s      r(   r!   r!   {   s    *FHOr*   c                H     | dddd          }t          |ddd          }|S )	zI
    Obtain the reference data from read_csv with the Python engine.
    iodatacsvz	test1.csvr   Tpython)	index_colparse_datesr'   )r   )datapathfilepathdf_refs      r(   rI   rI      s4    
 xfe[99Hh!hOOOFMr*   r'   
str | Nonec                    dS )Nnsr1   )r!   r'   s     r(   get_exp_unitrM      s    4r*   expectedr   Nonec                |    d | j         _        t          ||          }| j                             |          | _         d S r=   )indexnamerM   as_unit)rN   r!   r'   units       r(   adjust_expectedrU      s6    HN&))D^++D11HNNNr*   c                |    | dk    r5|                     t          j                            d                     d S d S )Nr   z3Sheets containing datetimes not supported by pyxlsbreason)applymarkerr,   markxfail)r'   r:   s     r(   xfail_datetimes_with_pyxlsbr\      sT    KL   	
 	
 	
 	
 	
 r*   c                     e Zd Z ej        d          d             Zd Zd Zd Zd Z	d Z
ej                            d	g d
g dg dg dg dg dg          d             Zej                            d	ddgddgg          d             Zd Zd Zd Zd Zd Zd Zej                            dddg          d             Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zej                            d&d eg d'g d(g d'd)d*ej         d+gd,          fd-d.e!e!d, e e"g d'd-/           e"g d(d./           e"g d0e#/           e"d1d2ej         d3ge#/          d,          fg          d4             Z$d5 Z%d6 Z&ej        '                     e(            d78          d9             Z)ej                            d:i d;fd<d=id;fg          d>             Z*d? Z+ej                            d@dA edBdCgi          fdD edEgF          fg          dG             Z,dH Z-dI Z.dJ Z/dK Z0dL Z1dM Z2ej        3                    dN          dO             Z4dP Z5dQ Z6dR Z7ej                            dSdTdUdTgdTdUgdVdWdVgdVdWgg          dX             Z8dY Z9dZ Z:ej        j;        ej        j<        d[                         Z=e>j?        ej        j<        d\                         Z@ej        j<        d]             ZAej        jB        d^             ZCd_ ZD e>jE        d`          da             ZFdb ZGdc ZHdd ZIej                            dedfej         dgdhdggfdiej         gdjz  fg          dk             ZJdl ZKdm ZLdn ZMdo ZNdp ZOdq ZPdr ZQds ZRej                            dtdudvdUd;gdUdfdudwddUd;gdfdudxdUd;gdUd;gdfdudydUd;gdUdfdzd{dddUdgfdzd{ddd| fg          d}             ZSd~ ZTd ZUd ZVd ZWd ZXd ZYd ZZd Z[dS )TestReadersTautousec                    t          t          j        |          }|                     |ddd                     |                    t          d|           dS )zG
        Change directory and set engine for read_excel calls.
        r'   rA   rB   excel
read_excelN)r   pdrd   chdirsetattrselfr'   rG   monkeypatchfuncs        r(   cd_and_set_enginezTestReaders.cd_and_set_engine   sX    
 r}V444((499:::Bd33333r*   c                   d }|                     t          j        d|           dddddd}t          d|z   d	          5 }t          j        |          }d d d            n# 1 swxY w Y   ||}n||d
d                   }||k    sJ d S )Nc                    | j         S r=   rb   )ri   argskwargss      r(   parserz,TestReaders.test_engine_used.<locals>.parser   s
    ;r*   parser   r   r   r   xlsxxlsmxlsbxlsodstest1rb   )rg   re   	ExcelFileopenrd   )	ri   r!   r'   rj   rq   expected_defaultsfresultrN   s	            r(   test_engine_usedzTestReaders.test_engine_used   s    	 	 	 	BL'6::: 
 
 'H$d++ 	&q]1%%F	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& HH(!""6H!!!!!!s    A!!A%(A%c           
     |   ddiddiddiddiddid}|dv rt          j        d          }n/|d	k    rt          j        d
          }nt          j        d          }|_t          j        t          |          5  t          j        d|z   dd||dd                              d d d            d S # 1 swxY w Y   d S d S )Nfooabcd{   TrueTrs   >   r   r   z8open_workbook() got an unexpected keyword argument 'foo'r   z/load() got an unexpected keyword argument 'foo'z8load_workbook() got an unexpected keyword argument 'foo'matchry   Sheet1r   r{   )
sheet_namerE   engine_kwargs)reescaper,   raises	TypeErrorre   rd   )ri   r!   r'   r~   msgs        r(   test_engine_kwargszTestReaders.test_engine_kwargs   s=    FOCLFO4=6?
 
 ''')WXXCCu__)NOOCC)WXXCy444  h&'"3HQRRL"A	                     s   8*B//B36B3c                H   d}t          j        t          |          5  t          j        d|z   ddd           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        d|z   dd	gdd
           d d d            d S # 1 swxY w Y   d S )Nz Passing an integer for `usecols`r   ry   r   r      r   rE   usecolsSheet2r{   r   skiprowsrE   r   r,   r   
ValueErrorre   rd   ri   r!   r   s      r(   test_usecols_intzTestReaders.test_usecols_int   sB   0]:S111 	 	M("x1a   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]:S111 	 	M("#   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s#   AA
A
,BBBc                (   t          ||           |ddg         }t          |||           t          j        d|z   ddg d          }t          j        d|z   dd	gdg d
          }t	          j        ||           t	          j        ||           d S )NBCry   r   r   )r      r   r   r   r{   r   r\   rU   re   rd   tmassert_frame_equal)ri   r:   r'   r!   rI   rN   df1df2s           r(   test_usecols_listzTestReaders.test_usecols_list   s    #FG4443*%(F333mh8q)))
 
 
 mhSII
 
 
 	c8,,,
c8,,,,,r*   c                   t          ||           |g d         }t          |||           t          j        d|z   ddd          }t          j        d|z   ddgdd	          }t	          j        ||           t	          j        ||           |d
dg         }t          |||           t          j        d|z   ddd          }t          j        d|z   ddgdd	          }t	          j        ||           t	          j        ||           t          j        d|z   ddd          }t          j        d|z   ddgdd	          }t	          j        ||           t	          j        ||           d S )NAr   r   ry   r   r   zA:Dr   r   r{   r   r   r   zA,C,DzA,C:Dr   )ri   r:   r'   r!   rI   rN   r   df3s           r(   test_usecols_strzTestReaders.test_usecols_str  s   #FG444///*(F333mh8q%
 
 
 mhS
 
 
 	c8,,,
c8,,,3*%(F333mh8q'
 
 
 mhS
 
 
 	c8,,,
c8,,,mh8q'
 
 
 mhS
 
 
 	c8,,,
c8,,,,,r*   r   )r   r{   r   )r   r   r{   )r{   r   r   )r{   r   r   )r   r   r{   )r   r{   r   c                    t          ||           |ddg         }t          |||           t          j        d|z   dd|          }t	          j        ||           d S )Nr   r   ry   r   r   r   r   )ri   r:   r'   r!   r   rI   rN   r   s           r(   .test_usecols_diff_positional_int_columns_orderz:TestReaders.test_usecols_diff_positional_int_columns_order5  ss     	$FG4443*%(F333h8q'
 
 
 	fh/////r*   r   Dc                    |ddg         }t          t          |                    |_        t          j        d|z   d|          }t          j        ||           d S )Nr   r   ry   r   r   r   )rangelenrQ   re   rd   r   r   )ri   r!   r   rI   rN   r   s         r(   .test_usecols_diff_positional_str_columns_orderz:TestReaders.test_usecols_diff_positional_str_columns_orderE  sZ    3*%s8}}--w1hPWXXX
fh/////r*   c                    t          ||           |}t          |||           t          j        d|z   dd          }t	          j        ||           d S Nry   r   r   r   rE   r   ri   r:   r'   r!   rI   rN   r   s          r(   test_read_excel_without_slicingz+TestReaders.test_read_excel_without_slicingM  s^    #FG444(F333w1hRSTTT
fh/////r*   c                    t          ||           |ddg         }t          |||           t          j        d|z   ddd          }t	          j        ||           d S )Nr   r   ry   r   r   zA,D:Er   r   r   s          r(   test_usecols_excel_range_strz(TestReaders.test_usecols_excel_range_strV  sq    #FG4443*%(F333h8q'
 
 
 	fh/////r*   c                    d}t          j        t          |          5  t          j        d|z   dd           d d d            d S # 1 swxY w Y   d S )NzInvalid column name: E1r   ry   r   zD:E1r   r   r   s      r(   $test_usecols_excel_range_str_invalidz0TestReaders.test_usecols_excel_range_str_invalida  s    ']:S111 	S 	SM'H,6RRRR	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S   AA
A
c                    d}t          j        t          |          5  t          j        d|z   ddgddg           d d d            d S # 1 swxY w Y   d S )Nz(list indices must be integers.*, not strr   ry   r   r   r   r   r,   r   r   re   rd   r   s      r(   test_index_col_label_errorz&TestReaders.test_index_col_label_errorg  s    8]9C000 	 	M("#%c
	   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A

AAc                    t          j        d|z   dd          }t          g dt          g d                    }t	          j        ||           d S )Nry   Sheet3r   r   )r   r   r   EFrR   columnsrQ   )re   rd   r   r   r   r   ri   r!   r   rN   s       r(   test_index_col_strzTestReaders.test_index_col_strr  se    w1hRUVVV---U2C5H5H5H
 
 
 	fh/////r*   c           	         t          j        d|z   dg d          }t          g dt          g gdz  g gdz  g d                    }t	          j        ||           d S )	Nry   r   r   r   )r   r   r   r   levelscodesnamesr   )re   rd   r   r   r   r   r   s       r(   test_index_col_emptyz TestReaders.test_index_col_emptyz  s    h8
 
 
 #OORD1HRD1HOOOTTT
 
 
 	fh/////r*   rE   Nr   c                    t          j        d|z   d|          }t          g dg dgg d          }|r |                    |j        |                   }t          j        ||           d S )Nry   Sheet4r   )i1ax)i2by)z
Unnamed: 0col1col2r   )re   rd   r   	set_indexr   r   r   )ri   r!   rE   r   rN   s        r(   test_index_col_with_unnamedz'TestReaders.test_index_col_with_unnamed  s     h8y
 
 
 ///0:X:X:X
 
 
  	G))(*:9*EFFH
fh/////r*   c                    d}t          j        t          |          5  t          j        d|z   dg           d d d            d S # 1 swxY w Y   d S )NzEUsecols do not match columns, columns expected but not found: \['E'\]r   ry   r   r   r   r   s      r(   %test_usecols_pass_non_existent_columnz1TestReaders.test_usecols_pass_non_existent_column  s     	 ]:S111 	= 	=M'H,se<<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=r   c                    d}t          j        t          |          5  t          j        d|z   ddg           d d d            d S # 1 swxY w Y   d S )Nz['usecols' must either be list-like of all strings, all unicode, all integers or a callable.r   ry   E1r   r   r   r   s      r(   test_usecols_wrong_typez#TestReaders.test_usecols_wrong_type  s    D 	
 ]:S111 	A 	AM'H,tQi@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   AAAc                    t          j        d|z   d          }t          ddggddg          }t          j        ||           d S )	Ntest2r   r   aaaabbbbbTestTest1r   re   rd   r   r   r   )ri   r!   parsedrN   s       r(   test_excel_stop_iteratorz$TestReaders.test_excel_stop_iterator  sS    w1hGGGvw/067:KLLL
fh/////r*   c                <   t          ||           |dk    r9|dk    r3|                    t          j                            d                     t          j        d|z   d          }t          t          j	        ggdg	          }t          j        ||           d S )
Nr   r   z+Calamine can't extract error from ods filesrW   test3r   r   r   r   )r\   rY   r,   rZ   r[   re   rd   r   npnanr   r   )ri   r:   r'   r!   r   rN   s         r(   test_excel_cell_error_naz$TestReaders.test_excel_cell_error_na  s    #FG444 ZH$6$6!!)V!WW   w1hGGGrvhZ&:::
fh/////r*   c                   t          ||           |}t          |||           t          j        d|z   dd          }t          j        d|z   ddgd          }t	          j        ||           t	          j        ||           t          j        d|z   ddd          }t	          j        ||j        d d	                    d S )
Nry   r   r   r   r   r{   r   r   rE   r   rE   
skipfooter)r\   rU   re   rd   r   r   iloc)	ri   r:   r'   r!   rI   rN   r   r   r   s	            r(   test_excel_tablezTestReaders.test_excel_table  s    #FG444(F333mGh.8qQQQmh8qcQ
 
 
 	c8,,,
c8,,,mh8qQ
 
 
 	c38CRC=11111r*   c                   t          ||           t          ||          }t          j        g dg dg dg dg dt	          t          ddd          t          ddd	          t          d
dd          t          ddd          t          ddd          gd| d          d          }d}t          j        ||z   d          }t          j	        ||           |
                                }d|j        |j        d         df<   t          j        ||z   d          }t          j	        ||           t          |j                  D ]I\  }	}
t          j        ||z   d|	          }|                    |
          }t          j	        ||           J|d                             t"                    |d<   t          j        ||z   ddt"          i          }t          j	        ||           d S )N)r{   r      r   )g      ?g      @gHzG?gQ?g&.>)TFTTF)r{   r   r   r      )r   r   cdei  
         iq  r{         i  r   M8[]dtype)IntColFloatColBoolColStrColStr2ColDateCol
test_typesr   r   g      @r  r   r  r   
converters)r\   rM   r   	from_dictr   r   re   rd   r   r   copylocrQ   	enumerater   r   applyr"   )ri   r:   r'   r!   rT   rN   basenameactualfloat_expectedicolrR   exps               r(   test_reader_special_dtypesz&TestReaders.test_reader_special_dtypes  s,   #FG444Hf--&***BBB;;;)//222  r2.. r2.. q!,, r2.. q"-- (---	 	 	 
 
&   x(2xHHH
fh/// "AD>/2I=>x(2xHHH
fn555 $H$455 	/ 	/JD$]8#D  F $$T**C!&#....%h/55c::xH(C
 
 
 	fh/////r*   c           
         d}t          j        g ddt          j        dddgg ddt          j        d	d
dgd          }d d d d d}t	          j        ||z   d|          }t          j        ||           d S )Ntest_converters)r{   r   r   r   g      )@gL2@g3333333@g:0y5>)Foundr   r   	Not foundr   1345)r	  r
  r  r  c                0    | dk    rt          |           ndS )N r  )intr   s    r(   <lambda>z4TestReaders.test_reader_converters.<locals>.<lambda>
  s    !r''Au r*   c                (    | rd| z  nt           j        S )Nr   )r   r   r)  s    r(   r*  z4TestReaders.test_reader_converters.<locals>.<lambda>  s    A"9"q&&26 r*   c                    | dk    rdndS )Nr'  r   r!  r1   r)  s    r(   r*  z4TestReaders.test_reader_converters.<locals>.<lambda>  s    AGG r*   c                (    | rt          |           ndS )Nr'  )r"   r)  s    r(   r*  z4TestReaders.test_reader_converters.<locals>.<lambda>  s    1,Q" r*   )r	  r
  r   r   r   r  )r   r  r   r   re   rd   r   r   )ri   r!   r  rN   r  r  s         r(   test_reader_convertersz"TestReaders.test_reader_converters  s    $&...!264{CLLLS#6	 
 
 =<99<<,,	
 

 xH
 
 
 	fh/////r*   c           	     p   d}t          j        ||z             }t          g dg dg dddt          j        dgd          }t          j        ||           t          j        ||z   dd	t          d
          }|d                             d          |d<   |d                             d	          |d<   t          g dt                    |d<   t          j        ||           d}t          j        t          |          5  t          j        ||z   ddi           d d d            d S # 1 swxY w Y   d S )N	testdtyper{   r   r   r         @      @      @      @      ?       @      @r   r   r   r   float64float32)r   r   r   r  r   r   001002003004r   z(Unable to convert column d to type int64r   r   int64)re   rd   r   r   r   r   r   r"   astyper   objectr,   r   r   )ri   r!   r  r  rN   r   s         r(   test_reader_dtypezTestReaders.test_reader_dtype  s   x(233!\\)))!\\3,	 
 
 	fh///xYYS'Q'Q
 
 
 !,,Y77 ,,Y77;;;6JJJ
fh///8]:S111 	E 	EM(X-c7^DDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es   D++D/2D/zdtype,expectedr1  r2  r7  r8  r9  r:  r;  r<  r  r=  r"  2r$  c                f    d}t          j        ||z   |          }t          j        ||           d S )Nr0  r  re   rd   r   r   )ri   r!   r  rN   r  r  s         r(   test_reader_dtype_strz!TestReaders.test_reader_dtype_str4  s;    : x(2%@@@
fh/////r*   c                  	
 |dv rt          j        d| d           t          t          ddgd          t          dd	gd
          t          ddgd          t          ddgd          t          t          j        dgd          t          t          j        dgd
          t          t          j        dgd          t          t          j        dgd          t          t	          j        d          gdz            t          t          j        t          j        gd          d
          	t          j        |          5 }		                    |dd           t	          j
        |d|          }d d d            n# 1 swxY w Y   |dk    rdd l
ddlm t          	
fd	j        D                       } |d         j        j                            
                    d                              |d<    
                    d d g                    |d <   n4	}t'          ||          }|d                             d!| d"          |d<   t          j        ||           d S )#Nr   r   No engine for filetype: ''r{   r   Int64r  r3  r5  Float64TFbooleanr   r   string   g      @z
2019-12-31r   )
r   r   r   r   r   r   ghijtestr   rQ   r   dtype_backendpyarrowr   )ArrowExtensionArrayc           	     ^    i | ])}|                      |         d                     *S )T)from_pandas)array)r3   colr\  dfpas     r(   
<dictcomp>z2TestReaders.test_dtype_backend.<locals>.<dictcomp>t  sK        ,,RXXbg4X-P-PQQ  r*   rU  us)rT   rV  r  r  )r,   skipr   r   re   NA	Timestampr   ensure_cleanto_excelrd   r[  pandas.arraysr\  r   r_  	_pa_arraycast	timestamprM   rC  r   )ri   r!   rZ  r'   	file_pathr   rN   rT   r\  ra  rb  s           @@@r(   test_dtype_backendzTestReaders.test_dtype_backendV  s   (((K?H???@@@QF'222S#Ji888T5M;;;S#Jh777RUAJg666RUCL	:::RUDM;;;RUCL999R\,7781<==RUBEN'::: 
 
 _X&& 	)KK	fEKBBB]fM  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 I%%    999999      !z   H 0/#-222<<T<3J3JKK HSM 0/$0F0FGGHSMMH&11D$SM00t??HSM
fh/////s   0FF	Fc                t   |dv rt          j        d| d           t          t          j        dgdt          j        gd          }t          j        |          5 }|                    |dd	           t          j	        |dd
d          }d d d            n# 1 swxY w Y   t          j
        ||           d S )NrK  rL  rM  r7  r3  r   r   rW  FrX  numpy_nullabler;  )r   rZ  r  )r,   re  r   r   r   r   rh  ri  re   rd   r   )ri   r!   ra  rn  r   s        r(   test_dtype_backend_and_dtypez(TestReaders.test_dtype_backend_and_dtype  s   (((K?H???@@@bfc]#rv??@@_X&& 	)KK	fEKBBB]!.	  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	fb)))))s   1BBBzinfer_string takes precedencerW   c           
         |dv rt          j        d| d           t          j        d          }t          j        d|          5  t          t          j        ddgt          j                  t          j        d	t          j	        gt          j                  d
          }t          j        |          5 }|                    |dd           t          j        |dd          }d d d            n# 1 swxY w Y   |dk    rwt          t          t          j        ddgt          j                            t          t          j        d	t          j	        gt          j                            d
          }nVt          t          |                    ddg                    t          |                    d	d g                    d
          }t          j        ||           d d d            d S # 1 swxY w Y   d S )NrK  rL  rM  r[  zmode.string_storager   r   r  r   rq  rW  FrX  rr  rY  rD   )r,   re  importorskipre   option_contextr   r   r_  object_rf  r   rh  ri  rd   r   r   r   )ri   r!   string_storagerb  ra  rn  r   rN   s           r(   test_dtype_backend_stringz%TestReaders.test_dtype_backend_string  si   
 (((K?H???@@@ ++4nEE 	4 	43*BJ???3,bjAAA  B ** iI&FFF&@P                 ))$(3*BJ)O)O)OPP(3,bj)Q)Q)QRR   %-bhhSz.B.BCC-bhhT{.C.CDD   !&(3337	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s8   A1G370C3'G33C7	7G3:C7	;C+G33G7:G7zdtypes, exp_valuer{   a.1rB  c                D   d}dt           i|}|                                }t          j        ||z   |          }t	          t          dgt                     t          |g|st           nd           d          }||k    s
J d            t          j        ||           d S )Ndf_mangle_dup_col_dtypesr   r  r{   )r   rz  zdtype dict changed)rD  r  re   rd   r   r   r   r   )	ri   r!   dtypes	exp_valuer  
dtype_dictdtype_dict_copyr   rN   s	            r(   test_dtype_mangle_dup_colsz&TestReaders.test_dtype_mangle_dup_cols  s     .6,V,
$//++x(2*EEEQCv...ykv1O4PPP 
 
 _,,,.B,,,
fh/////r*   c                    d}t          j        ||z             }t          dg di          }t          j        ||           d S )Ntest_spacestestcol)zthis is greatz4    spacesz1 trailing z
 1 leadingz2  spaces  multiple  timesr   )ri   r!   r  r  rN   s        r(   test_reader_spaceszTestReaders.test_reader_spaces  s\     x(233   

 

 	fh/////r*   zbasename,expectedzgh-35802COLUMNzTest (1)zgh-36122z
got 2nd sar   c                    |dk    rt          j        d|            t          j        ||z             }t	          j        ||           d S )Nr   zSkipped for engine: )r,   re  re   rd   r   r   )ri   r'   r!   r  rN   r  s         r(   test_read_excel_ods_nested_xmlz*TestReaders.test_read_excel_ods_nested_xml  sS     U??K7v77888x(233
fh/////r*   c                    d}t          j        ||z   d           }g d}t          j        ||                                           |t          |                                          k    sJ d S )Ntest_multisheetr   )CharlieAlphaBeta)re   rd   r   assert_contains_allkeyslistri   r!   r  dfsexpected_keyss        r(   test_reading_all_sheetsz#TestReaders.test_reading_all_sheets  sq     %mHx/DAAA444
}chhjj999 SXXZZ 0 0000000r*   c                2   d}g d}t          j        ||z   |          }t          t          |                    }t	          j        ||                                           t          |          t          |                                          k    sJ d S )Nr  )r   r  r  r   )re   rd   r  setr   r  r  r   )ri   r!   r  r  r  s        r(   %test_reading_multiple_specific_sheetsz1TestReaders.test_reading_multiple_specific_sheets  s     %111mHx/MJJJS//00
}chhjj999=!!S__444444r*   c                    d}t          j        ||z   d           }g d}t          j        ||                                           d S )Nblank_with_headerr   )r   r   r   )re   rd   r   r  r  r  s        r(   "test_reading_all_sheets_with_blankz.TestReaders.test_reading_all_sheets_with_blank  sN     'mHx/DAAA666
}chhjj99999r*   c                z    t          j        d|z   d          }t          j        |t	                                 d S )Nblankr   r   )re   rd   r   r   r   )ri   r!   r  s      r(   test_read_excel_blankz!TestReaders.test_read_excel_blank  s8    w1hGGG
fikk22222r*   c                    t          ddg          }t          j        d|z   d          }t          j        ||           d S )Ncol_1col_2r   r  r   r   )r   re   rd   r   r   )ri   r!   rN   r  s       r(   !test_read_excel_blank_with_headerz-TestReaders.test_read_excel_blank_with_header  sJ    gw%78882X=(SSS
fh/////r*   c                @   t          j        t          d          5  t          j        d|z   dgd            d d d            n# 1 swxY w Y   t          j        t
          d          5  t          j        d|z   d d            d d d            d S # 1 swxY w Y   d S )	Nz \(sheet: Sheet1\)$r   r  r{   )headerr   ry   c                    ddz  S )Nr{   r   r1   r)  s    r(   r*  zHTestReaders.test_exception_message_includes_sheet_name.<locals>.<lambda>#  s
    A r*   )r   r   )r,   r   r   re   rd   ZeroDivisionErrorri   r!   s     r(   *test_exception_message_includes_sheet_namez6TestReaders.test_exception_message_includes_sheet_name  sL   ]:-CDDD 	W 	WM-8!QUVVVV	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W],4JKKK 	X 	XM'H,ooRVWWWW	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	Xs#   AAA*BBBz-ignore:Cell A4 is marked:UserWarning:openpyxlc                   t          ||           t          t          j        d          dgt          j        d          dgddggddg	          }|d
k    r3|                    t
          j                            d                     |7|dv r3|                    t
          j                            d                     t          j        d|z             }t          j
        ||           d S )Nz
2016-03-12zMarc Johnsonz
2016-03-16z
Jack Blackg@xDzTimothy BrownDateColWithBigInt	StringColr   r   zMaybe not supported by openpyxlrW   )r   r   z)Defaults to openpyxl, maybe not supportedtestdateoverflow)r\   r   re   rg  rY   r,   rZ   r[   rd   r   r   )ri   r:   r'   r!   rN   r   s         r(   test_date_conversion_overflowz)TestReaders.test_date_conversion_overflow%  s    	$FG444l++^<l++\:'
 )+6
 
 
 Z!!)J!KK   >h*<<<!!)T!UU   1H<==
fh/////r*   c                   t          ||           d}d}|}t          |||           t          j        ||z   |d          }t          j        ||z   d|          }	t	          j        ||           t	          j        |	|           d S Nry   r   r   r   )rE   r   r   )
ri   r:   r!   r'   rI   filenamer   rN   r   r   s
             r(   test_sheet_namezTestReaders.test_sheet_nameA  s    #FG444
(F333mxJ!
 
 
 mHx/1TTT
c8,,,
c8,,,,,r*   c                    d|z   }t          j        |dd          }t          |d          5 }t          j        |dd          }t          j        ||           d d d            d S # 1 swxY w Y   d S )Nry   r   r   r   rz   )re   rd   r}   r   r   )ri   r!   pthrN   r   r  s         r(   test_excel_read_bufferz"TestReaders.test_excel_read_bufferR  s     =QGGG#t__ 	4]1QGGGF!(F333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   -A''A+.A+c                    d}t          j        t          d          5  t          j        d|           d d d            d S # 1 swxY w Y   d S )Nr   zUnknown engine: foor   r'  rb   r   )ri   
bad_engines     r(   test_bad_engine_raisesz"TestReaders.test_bad_engine_raisesY  s    
]:-BCCC 	1 	1M"Z0000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   AA	Ar   r   r   r   r   c                    d}t          j        t          |          5  t          j        d|z   |           d d d            d S # 1 swxY w Y   d S Nz?Worksheet index 3 is invalid|Worksheet named 'Sheet4' not foundr   r  r   r   )ri   r!   r   r   s       r(   test_bad_sheetname_raisesz%TestReaders.test_bad_sheetname_raises^  s     P]:S111 	E 	EM'H,DDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E   AA	A	c                    d| }d                     g d          }t          j        t          |          5  t	          j        |           d d d            d S # 1 swxY w Y   d S )Nr   |)z(No such file or directoryu   没有那个文件或目录zFile o directory non esistente)r   )joinr,   r   FileNotFoundErrorre   rd   )ri   r!   bad_filer   s       r(   test_missing_file_raisesz$TestReaders.test_missing_file_raisesh  s    ###  
 
 ],E::: 	$ 	$M(###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   AA!Ac                   d}|
t           }d}n+|dk    rddlm} |}d}n|dk    rddlm} |}d	}n	t
          }d
}t          j        ||          5  t          j	        t          |                     d d d            d S # 1 swxY w Y   d S )Ns   foozLExcel file format cannot be determined, you must specify an engine manually.r   r   )	XLRDErrorzFUnsupported format, or corrupt file: Expected BOF record; found b'foo'r   CalamineErrorzCannot detect file formatzFile is not a zip filer   )r   r   r  r    r  r
   r,   r   re   rd   r   )ri   r'   
bad_streamerrorr   r  r  s          r(   test_corrupt_bytes_raisesz%TestReaders.test_corrupt_bytes_raisesu  s   
>E. C v&&&&&&E' C z!!555555!E-CCE*C]5,,, 	/ 	/M'*--...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   "A??BBc                6   t          d|z   d          5 }|                    |                                           d d d            n# 1 swxY w Y   t          j        |j                  }t          j        d|z             }t          j        ||           d S )Nry   rz   )content)r}   serve_contentreadre   rd   urlr   r   )ri   
httpserverr!   r   	url_tablelocal_tables         r(   test_read_from_http_urlz#TestReaders.test_read_from_http_url  s     'H$d++ 	7q$$QVVXX$666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7M*.11	mGh$677
i55555s   )A		AAc                0   t          d|z   d          5 }|                    d|z   |           d d d            n# 1 swxY w Y   d|j         d|z   }t          j        ||          }t          j        d|z             }t          j        ||           d S )Nry   rz   KeyBodys3:///test1)storage_options)r}   
put_objectrR   re   rd   r   r   )ri   r!   s3_public_buckets3sor   r  r  r  s           r(   test_read_from_s3_urlz!TestReaders.test_read_from_s3_url  s     'H$d++ 	Hq''Gh,>Q'GGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 4&+333h>M#t<<<	mGh$677
i55555s   ;??c                   t          d|z   d          5 }|                    d|z   |           d d d            n# 1 swxY w Y   dd l} |j        di |}|                     d|j         d|z             5 }t          j        |          }d d d            n# 1 swxY w Y   t          j        d|z             }t          j        ||           d S )Nry   rz   r  r   r  r  r1   )	r}   r  s3fsS3FileSystemrR   re   rd   r   r   )	ri   r!   r  r  r   r  s3r  r  s	            r(   test_read_from_s3_objectz$TestReaders.test_read_from_s3_object  ss    'H$d++ 	Hq''Gh,>Q'GGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	T&&&&WW:-2:::XEFF 	)!a((I	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) mGh$677
i55555s   ;??8BB Bc                   t           j                             |ddd          d|z             }t          j        |          }	 t          j        d|z             }n_# t
          $ rR d                    t          j                                                              }t          j
        d|            Y nw xY wt          j        ||           d S )NrA   rB   rc   ry   zfile://localhost/ zfailing on )ospathr  re   rd   r	   platformunamestripr,   re  r   r   )ri   r!   rG   
localtabler  r  platform_infos          r(   test_read_from_file_urlz#TestReaders.test_read_from_file_url  s     W\\((4"A"A7XCUVV
mJ//	7&9J&FGGII 	7 	7 	7HHX^%5%566<<>>MK5m5566666	7
 	i55555s   A AB87B8c                    d|z   }t          j        |dd          }t          d|z             }t          j        |dd          }t          j        ||           d S r   )re   rd   r   r   r   )ri   r!   str_pathrN   path_objr  s         r(   test_read_from_pathlib_pathz'TestReaders.test_read_from_pathlib_path  sc    X%=h!LLL(*++xHJJJ
h/////r*   zpy.pathc                   ddl m} t          j                            d|z             }t          j        |dd          } |                                d|z             }t          j        |dd          }t          j        ||           d S )Nr   )localry   r   r   )	py.pathr  r  r  r  re   rd   r   r   )ri   r!   	LocalPathr  rN   r  r  s          r(   test_read_from_py_localpathz'TestReaders.test_read_from_py_localpath  s     	/.....7<<( 233=h!LLL9;;##Gh$677xHJJJ
h/////r*   c                    t           j                            d|z             }t          |d          5 }t	          j        |dd          }~|                                 d d d            d S # 1 swxY w Y   d S )Nry   rz   r   r   r   )r  r  r  r}   re   rd   r  )ri   r!   r  r   r   s        r(   test_close_from_py_localpathz(TestReaders.test_close_from_py_localpath  s    7<<( 233(D!! 	QaHBBBAFFHHH		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   -A--A14A1c                   t          ||           |dk    r9|dk    r3|                    t          j                            d                     t          j        dt          ddd          t          dd	d
d          t          dddd          t          dddd          t          dddd          t          dddd          t          dddd          t          ddd d!          t          d d"dd#          t          d$d%d&d'          t          d(d)d*          gi          }t          j	        d+|z   d,-          }t          j        ||           t          j	        d.|z   d,-          }t          j        ||           d S )/Nr   r   z0ODS file contains bad datetime (seconds as text)rW   Timer{   r   r   -   8   i r      1   i@ rR     *   i    9   #   i 	   )      i           i'	 r  i`
 5   i 5    %   r   i       6   
times_1900r   r   
times_1904)r\   rY   r,   rZ   r[   r   r  r   re   rd   r   r   )ri   r:   r'   r!   rN   r  s         r(   test_reader_secondszTestReaders.test_reader_seconds  s   #FG444 ZH$6$6!!M "     &AqMMBF++BF++BF++BF++BF++RV,,QF++RF++RF++R$$
 
$ |h68LLL
fh///|h68LLL
fh/////r*   c           
     |   t          ||           t          ||          }t          j        ddgddgg          }d|z   }t	          ddt          j        d          d	gd
dt          j        d          dgddt          j        d          dgddt          j        d          d	gg|          }||d
                                      d| d          ||d
         <   t          j        |dddgd          }t          j
        ||           ||_        g d|_        t          j        |dddg          }t          j
        ||           ||_        t          j        |dddgddg          }t          j
        ||           g d|_        |                    dd g          |_        t          j        |d!ddg          }t          j
        ||           t          t          d                    |_        |                    d"d#g          |_        t          j        |d$ddgd          }t          j
        ||           |                    dd
gd%                              d"d#g          |_        t          j        |d&dddg          }t          j
        ||           |                    d"d#g          |_        |                    dd g          |_        t          j        |d'ddgddg          }t          j
        ||           t          j        |d(ddgddgd
)          }t          j
        ||           d S )*Nr   barr   r   testmultiindexr{   r3  
2015-01-01Tr   r4  
2015-01-02Fr   r5  
2015-01-03r   r6  
2015-01-04r   r  r  	mi_columnr   )r   r  rE   r:  mi_indexr   bothr   rE   r  ilvl1ilvl2mi_index_namec1c2mi_column_name)levelname_with_int	both_nameboth_name_skiprows)r   rE   r  r   )r\   rM   r   from_productr   re   rg  rC  rd   r   r   rQ   r   	set_namesr  r   
set_levels)	ri   r:   r'   r!   rT   mimi_filerN   r  s	            r(   test_read_excel_multiindexz&TestReaders.test_read_excel_multiindex
  s   #FG444Hf--$uensCj%ABB"X- Cl33T:Cl33U;Cl33U;Cl33T:	 
 
 
 #2a5/00t??AQFa
 
 
 	fh/// ///w:!QPPP
fh/// 1a&!Q
 
 
 	fh/// 0//w&899w?qRSfUUU
fh/// eAhh<<t55 0!Q1
 
 
 	fh/// ==!Qq=99CCT4LQQ1aV
 
 
 	fh/// <<t55w&8991vq!f
 
 
 	fh/// +!fq6
 
 
 	fh/////r*   zsheet_name,idx_lvl2both_name_blank_after_mi_namer   r   both_name_multiple_blanksr   c           
     Z   t          ||           d|z   }t          j        ddgddggddg          }t          ||          }t	          d	d
t          j        d          dgddt          j        d          dgddt          j        d          dgddt          j        d          dgg|t          j        g d|fddg                    }	|	|d                                      d| d          |	|d         <   t          j	        ||dd	gdd	g          }
t          j        |
|	           d S )Nr  r   r  r   r   r  r  r   r{   r3  r  Tr   r4  r  Fr   r5  r  r   r6  r  )r   r   r  r  r  r  r   r  r  r   r  )r\   r   r%  rM   r   re   rg  from_arraysrC  rd   r   r   )ri   r:   r'   r!   r   idx_lvl2r)  r(  rT   rN   r   s              r(   +test_read_excel_multiindex_blank_after_namez7TestReaders.test_read_excel_multiindex_blank_after_name^  sg    	$FG444"X-$uensCj%A$PTVVVHf--Cl33T:Cl33U;Cl33U;Cl33T:	 (---x8(  
 
 
 #2a5/00t??A!!fq6	
 
 
 	fh/////r*   c                    d|z   }t          j        |dddg          }t          j        ddg          }t	          g dgd	z  |
          }t          j        ||           d S )Nr  index_col_noner   r{   r   r  r   r   keyvalr1  r   r   )re   rd   r   r%  r   r   r   )ri   r!   r)  r   exp_columnsrN   s         r(   &test_read_excel_multiindex_header_onlyz2TestReaders.test_read_excel_multiindex_header_only  su     #X-w3CQPQFSSS -z>.JKKlll^a/EEE
fh/////r*   c           	        d|z   }t          j        t           j        t           j        t           j        t           j        t           j        gg dg dg dg dg dgt                    }g d}t	          g d	g d
gg dg dgd d g          }t          g d	d           }t          |||          }t          j        |dd          }t          j
        ||           ||_        t          j        |dddg          }t          j
        ||           t          j        g dg dg dg dg dg          }g d}t	          g dg dgg dg dgd d g          }t          g dd           }t          |||          }t          j        |dd          }t          j
        ||           ||_        t          j        |dddg          }t          j
        ||           d S )Ntest_index_name_pre17)R0C0R0C1R0C2R0C3R0C4)R1C0R1C1R1C2R1C3R1C4)R2C0R2C1R2C2R2C3R2C4)R3C0R3C1R3C2R3C3R3C4)R4C0R4C1R4C2R4C3R4C4r  )C_l0_g0C_l0_g1C_l0_g2C_l0_g3C_l0_g4)R0R_l0_g0R_l0_g1R_l0_g2R_l0_g3R_l0_g4)R1R_l1_g0R_l1_g1R_l1_g2R_l1_g3R_l1_g4)r   r{   r   r   r   r   r   r   rQ   r   single_namesr   r   multi_namesr{   )r\  r]  r^  r_  r`  )rb  rc  rd  re  rf  )r   r{   r   r   r   single_no_namesmulti_no_names)r   r_  r   rD  r   r   r   re   rd   r   r   rQ   )	ri   r!   r  rB   r   r(  sirN   r  s	            r(   test_excel_old_index_formatz'TestReaders.test_excel_old_index_format  s   *X5
 x8888888888888888 

 

 

 JIIMMMMMM &%%'9'9'9:,
 
 
 IIIPT
 
 
 TW===xNaPPP
fh///xMaQRVTTT
fh/// x888888888888888
 
 JIIGGGGGG #??OOO4,
 
 
 JJJQUVVVTW===x4EQRSSS
fh///x4DQRTUPVWWW
fh/////r*   c                    d}dD ]N}t          j        t          |          5  t          j        d|z   |           d d d            n# 1 swxY w Y   Od S )Nz#Passing a bool to header is invalid)TFr   ry   r  r   )ri   r!   r   args       r(   test_read_excel_bool_header_argz+TestReaders.test_read_excel_bool_header_arg  s    3  	> 	>Cy444 > >g0====> > > > > > > > > > > > > > >	> 	>s   AA	A	c           
        t          ||           t          ||          }t          j        d|z   dddg          }t	          ddt          j        d          d	gdd
t          j        d          dgddt          j        d          dgddt          j        d          d	ggg d          }|d                             d| d          |d<   t          j        ||           t          j        d|z   dt          j
        ddg                    }t          j        ||           t          j        d|z   dd           }t          j        ||           t          j        d|z   ddg d          }t	          dd
t          j        d          dgddt          j        d          dgddt          j        d          d	ggg d          }|d                             d| d          |d<   t          j        ||           d S )Ntestskiprowsskiprows_listr   r   r   r   r{   r3  r  Tr4  r  Fr   r5  r  r   r6  r  r:  r   r   r  r  c                
    | dv S N)r   r   r1   r)  s    r(   r*  z6TestReaders.test_read_excel_skiprows.<locals>.<lambda>  s
    qF{ r*   )r   r   r   )r\   rM   re   rd   r   rg  rC  r   r   r   r_  ri   r:   r'   r!   rT   r  rN   s          r(   test_read_excel_skiprowsz$TestReaders.test_read_excel_skiprows  sX   #FG444Hf--X%/QPQF
 
 
 Cl33T:Cl33U;Cl33U;Cl33T:	 )((
 
 
 !,,]4]]];;
fh///X%&Xq!f%%
 
 

 	fh/// X%&**
 
 

 	fh///X%&&&&	
 
 
  Cl33U;Cl33U;Cl33T:	 )((
 
 
 !,,]4]]];;
fh/////r*   c                l   t          ||           t          ||          }t          j        d|z   dd           }t	          ddt          j        d          dgd	d
t          j        d          dggg d          }|d                             d| d          |d<   t          j        ||           d S )Nrs  rt  c                
    | dvS )N)r{   r   r   r1   r)  s    r(   r*  zFTestReaders.test_read_excel_skiprows_callable_not_in.<locals>.<lambda>  s    q	1 r*   ru  r{   r3  r  Tr   r5  r  Fr:  r   r   r  r  )	r\   rM   re   rd   r   rg  rC  r   r   rx  s          r(   (test_read_excel_skiprows_callable_not_inz4TestReaders.test_read_excel_skiprows_callable_not_in  s    #FG444Hf--X%&11
 
 

 Cl33T:Cl33U; )((
 
 
 !,,]4]]];;
fh/////r*   c                    d}t          j        d|z   |          }t          j        d|z             }|d |         }t          j        ||           d S )Nr   ry   nrowsrH  )ri   r!   num_rows_to_pullr  rN   s        r(   test_read_excel_nrowsz!TestReaders.test_read_excel_nrows-  s`    w19IJJJ=8!344---.
fh/////r*   c                    t          j        d|z             }t          |          }|dz   }t          j        d|z   |          }t          j        ||           d S )Nry   r   r~  )re   rd   r   r   r   )ri   r!   rN   num_records_in_filer  r  s         r(   0test_read_excel_nrows_greater_than_nrows_in_filez<TestReaders.test_read_excel_nrows_greater_than_nrows_in_file5  s`    =8!344!(mm.3w19IJJJ
fh/////r*   c                    d}t          j        t          |          5  t          j        d|z   d           d d d            d S # 1 swxY w Y   d S )Nz'nrows' must be an integer >=0r   ry   r%  r~  r   r   s      r(   +test_read_excel_nrows_non_integer_parameterz7TestReaders.test_read_excel_nrows_non_integer_parameter=  s    .]:S111 	9 	9M'H,C8888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9r  z-filename,sheet_name,header,index_col,skiprowsr  r  r  r  r   rs  rt  c                
    | dv S rw  r1   r)  s    r(   r*  zTestReaders.<lambda>K  s
    AK r*   c                    t          j        ||z   ||||          j        dd         }t          j        ||z   ||||d          }t          j        ||           dS )z
        For various parameters, we should get the same result whether we
        limit the rows during load (nrows=3) or after (df.iloc[:3]).
        )r   r  rE   r   Nr   )r   r  rE   r   r  )re   rd   r   r   r   )	ri   r!   r  r   r  rE   r   rN   r  s	            r(   test_read_excel_nrows_paramsz(TestReaders.test_read_excel_nrows_paramsC  s    & =x!
 
 
 rr x!
 
 
 	fh/////r*   c                    t          j        t          d          5  t          j        d|z   dd           d d d            d S # 1 swxY w Y   d S )Nzbut 3 positional argumentsr   ry   r   r   r   r  s     r(   test_deprecated_kwargsz"TestReaders.test_deprecated_kwargsg  s    ]9,HIII 	; 	;M'H,h:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   AA
Ac                    d|z   }g d}t          j        g dd          }t          ||d          }t          j        |dd	d
gd           }t          j        ||           d S )Nr  ))r   r   r6  r   r   r  ))r   r   r6  r{   r   r  )r   r{   r.  )r   r   rg  r3  r   r{   r  )r   from_tuplesr   re   rd   r   r   )ri   r!   	file_namerB   idxrN   r   s          r(   "test_no_header_with_list_index_colz.TestReaders.test_no_header_with_list_index_colk  s    $x/	;;;$888
 
 
 Tf==="2q!fT
 
 
 	h/////r*   c                    d|z   }dt           j        ddg}t          |dg          }t          j        |          }t          j        ||           d S )None_col_blank_lineg      ?r{   r   numbersr   )r   r   r   re   rd   r   r   )ri   r!   r  rB   rN   r   s         r(   test_one_col_noskip_blank_linez*TestReaders.test_one_col_noskip_blank_linex  sX    (83	RVQ"TI;777y))
fh/////r*   c                &   d|z   }t          j        ddg          }t          j        t          j        gt          j        t          j        gddgddgg}t	          ||          }t          j        |d	d
dg          }t          j        ||           d S )Nr  )r   r   )r   r   r{   r   r   r   r   mi_column_empty_rowsr   r4  )	r   r  r   r   r   re   rd   r   r   )ri   r!   r  r   rB   rN   r   s          r(    test_multiheader_two_blank_linesz,TestReaders.test_multiheader_two_blank_lines  s    $x/	(*j)ABB 2626"2QFQFCT7333"8!Q
 
 
 	fh/////r*   c                R    d|z   }t          j        |          }|j        dk    sJ dS )z
        Sheets can contain blank cells with no data. Some of our readers
        were including those cells, creating many empty rows and columns
        trailing_blanks)r   r   N)re   rd   shape)ri   r!   r  r   s       r(   test_trailing_blanksz TestReaders.test_trailing_blanks  s6    
 &0	y))|v%%%%%%r*   c                F   |dk    rt          j        d           |dk    r3|                    t           j                            d                     t          j        t          d          5  t          j        d|z   d	
           d d d            d S # 1 swxY w Y   d S )Nr   *chartsheets do not exist in the ODF formatr   4pyxlsb can't distinguish chartsheets from worksheetsrW   z"Worksheet named 'Chart1' not foundr   
chartsheetChart1r   	r,   re  rY   rZ   r[   r   r   re   rd   ri   r:   r'   r!   s       r(   test_ignore_chartsheets_by_strz*TestReaders.test_ignore_chartsheets_by_str  s   vKDEEEX!!Q "    
 ]:-QRRR 	H 	HM,1hGGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H   /BBBc                F   |dk    rt          j        d           |dk    r3|                    t           j                            d                     t          j        t          d          5  t          j        d|z   d	
           d d d            d S # 1 swxY w Y   d S )Nr   r  r   r  rW   z0Worksheet index 1 is invalid, 1 worksheets foundr   r  r{   r   r  r  s       r(   test_ignore_chartsheets_by_intz*TestReaders.test_ignore_chartsheets_by_int  s   vKDEEEX!!Q "    
 ]P
 
 
 	A 	A M,1a@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	Ar  c                    t          j        d|z   dd          }t          g dg dg dgg d	          }t          j        ||           d S )
Ntest_decimal,r{   )decimalr   )r{   gAc̝ė@g	hAABCpoig2[j@)r   gHzG^@g{G@DEFuytgUq&?)r   g%Cq@g^@GHIrezg)@)IdNumber1Number2Text1Text2Number3r   r   r   s       r(   test_euro_decimal_formatz$TestReaders.test_euro_decimal_format  sy    ~8#PQRRRFFF@@@CCC
 NMM
 
 
 	fh/////r*   )\__name__
__module____qualname__r,   fixturerl   r   r   r   r   r   rZ   parametrizer   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r.  rE  r   r   r   r"   r   rD  rI  ro  rs  r[   r   ry  r  r  r  r  r  r  r  r  r  filterwarningsr  r  r  r  r  r  r  network
single_cpur  tdskip_if_not_us_localer  r  slowr  r  
skip_if_nor  r  r  r*  r1  r:  rm  rq  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r1   r*   r(   r^   r^      s       V^D!!!4 4 "!4" " "0  4  $- - -*1- 1- 1-f [IIIyyy)))YYY			999U 0 0 0 [Y#sc3Z(@AA0 0 BA00 0 0	0 	0 	0S S S	 	 	0 0 0	0 	0 	0 [[4)440 0 540= = =A A A0 0 0
0 0 02 2 2&/0 /0 /0d0 0 04E E E: [ 	)\\111)\\!34	  
  icDD	#VLLL	BBB#V$8$8$8	JJJ#V$@$@$@OOO#VS#rvs$;6JJJ	  
	
 60 07 60.0 .0 .0`* * *  [""$$-L   "4 "4 "4H [0B7eW=Mq<Q2RSS0 0 TS0 0 0 0& [Hzl#;<<=L>:::;	
 0 0 01 1 15 5 5: : :3 3 30 0 0
X X X [ OPP0 0 QP06- - -"4 4 41 1 1
 [	
QFQFHx&:Xx<PQ E E	 E$ $ $/ / /6 [[6 6  6 [	6 	6  	6 [6 6 6  [6 6 60 0 0 R]9
0 
0 
0  "0 "0 "0HR0 R0 R0h [,rvsC.EF(26(Q,7	
 0 0 0B	0 	0 	0G0 G0 G0R> > >40 40 40l0 0 0,0 0 00 0 09 9 9 [7{QFAt<z4!Q>v1v1vt</!QDA_dD1a&A_dD:O:OP	

 
0 0
 
02; ; ;0 0 00 0 0	0 	0 	0& & &H H HA A A0 0 0 0 0r*   r^   c            
         e Zd Zd Z ej        d          d             Zd Zd Zej	        
                    dg d          d	             Zd
 Zd Zej	        
                    ddddgddgdddgddgg          d             Zd Zd Zd Zd Zd Zd Zej	        
                    dddg          d             Zd Zd Zd Zd Zd S )!TestExcelFileReadc                   d}t          j        t          |d          5  t          d|z   d          5 }t	          j        |                                |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NzPassing bytes to 'read_excel' is deprecated and will be removed in a future version. To read from a byte string, wrap it in a `BytesIO` object.F)r   raise_on_extra_warningsry   rz   rb   )r   assert_produces_warningFutureWarningr}   re   rd   r  )ri   r'   r!   r   r   s        r(   test_deprecate_bytes_inputz,TestExcelFileRead.test_deprecate_bytes_input  s   : 	 'e
 
 
 	7 	7 g($// 71affhhv66667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s4   B )A(B (A,	,B /A,	0B  BBTr_   c                    t          t          j        |          }|                     |ddd                     |                    t          d|           dS )zH
        Change directory and set engine for ExcelFile objects.
        rb   rA   rB   rc   r|   N)r   re   r|   rf   rg   rh   s        r(   rl   z#TestExcelFileRead.cd_and_set_engine  sX    
 r|F333((499:::BT22222r*   c                    dddddd}t          j        d|z             5 }|j        }d d d            n# 1 swxY w Y   ||}n||dd                   }||k    sJ d S )Nr   r   r   r   rs   ry   r{   )re   r|   r'   )ri   r!   r'   r~   rc   r   rN   s          r(   r   z"TestExcelFileRead.test_engine_used  s    
 
 \'H,-- 	"\F	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" HH(!""6H!!!!!!s   488c                n   t          j        d|z             5 }t          j        |dddg          }d d d            n# 1 swxY w Y   t          dgdgdgt          j        gdggd	g
          }t          j        ||           t          j        d|z             5 }t          j        |dddg          }d d d            n# 1 swxY w Y   t          t          j        gdgt          j        gt          j        gdggd	g
          }t          j        ||           t          j        d|z             5 }t          j        |dddg          }d d d            n# 1 swxY w Y   t          dgdgdgt          j        gdggd	g
          }t          j        ||           t          j        d|z             5 }t          j        |dddg          }d d d            n# 1 swxY w Y   t          t          j        gdgt          j        gt          j        gdggd	g
          }t          j        ||           d S )Ntest4r   Fappler   keep_default_na	na_valuesrf  r{   rabbitr   r   Ttest51.#QNANr   )re   r|   rd   r   r   r   r   r   )ri   r!   rc   r   rN   s        r(   test_excel_passes_naz&TestExcelFileRead.test_excel_passes_na  sV   \'H,-- 	](EgY  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 VaS4&26(XJ7&
 
 
 	fh///\'H,-- 	](DWI  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 fXsRVHrvh
;fX
 
 
 	fh/// \'H,-- 	](EgY  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 [1#w8*=x
 
 
 	fh///\'H,-- 	](DWI  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 fXsRVHrvh
;fX
 
 
 	fh/////sE   >AACCC2EEE5GG"G	na_filter)NTFc                h   i }|||d<   t          j        d|z             5 }t          j        |fdddgd|}d d d            n# 1 swxY w Y   |du rdgd	gd
gdgdgg}n*t          j        gd	gt          j        gt          j        gdgg}t          |dg          }t          j        ||           d S )Nr  r  r   Tr  r  Fr  r{   r   r  r   r   )re   r|   rd   r   r   r   r   r   )ri   r!   r  rp   rc   r   rN   s          r(   test_excel_passes_na_filterz-TestExcelFileRead.test_excel_passes_na_filter  s)     "+F;\'H,-- 	]# $")	 
  F	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 "aS5'G9xjIHH1#x"&H:FHXx888
fh/////s   AA	A	c                   t          ||           |}t          |||           t          j        d|z             5 }t          j        |dd          }t          j        |ddgd          }d d d            n# 1 swxY w Y   t          j        ||           t          j        ||           t          j        d|z             5 }|                    dd          }|                    ddgd          }d d d            n# 1 swxY w Y   t          j        ||           t          j        ||           t          j        d|z             5 }t          j        |ddd          }	d d d            n# 1 swxY w Y   t          j        |	|j        d d	                    t          j        d|z             5 }|                    ddd
          }	d d d            n# 1 swxY w Y   t          j        |	|j        d d	                    d S )Nry   r   r   r{   r   )rE   )r   rE   r   r   )rE   r   )	r\   rU   re   r|   rd   r   r   rr   r   )
ri   r:   r'   r!   rI   rN   rc   r   r   r   s
             r(   test_excel_table_sheet_by_indexz1TestExcelFileRead.test_excel_table_sheet_by_index'  s   #FG444(F333\'H,-- 	P-!qAAAC-!qcQOOOC	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	c8,,,
c8,,,\'H,-- 	<++a1+--C++a1#+;;C	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	c8,,,
c8,,,\'H,-- 	P-!qQOOOC	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P
c38CRC=111\'H,-- 	<++a1+;;C	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	c38CRC=11111sG   1A88A<?A<1DDDE22E69E66GG"Gc                   t          ||           |}t          |||           d}d}t          j        ||z             5 }|                    |d          }	d d d            n# 1 swxY w Y   t          j        ||z             5 }|                    d|          }
d d d            n# 1 swxY w Y   t          j        |	|           t          j        |
|           d S r  )r\   rU   re   r|   rr   r   r   )ri   r:   r'   r!   rI   rN   r  r   rc   	df1_parse	df2_parses              r(   r  z!TestExcelFileRead.test_sheet_nameB  s{   #FG444(F333
\(X-.. 	H%zQGGI	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H \(X-.. 	H%aJGGI	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	i222
i22222s#   A##A'*A'B))B-0B-r   r   r   r   r   c                    d}t          j        t          |          5  t          j        d|z             5 }|                    |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r  )r,   r   r   re   r|   rr   )ri   r!   r   r   rc   s        r(   r  z+TestExcelFileRead.test_bad_sheetname_raisesT  s     P]:S111 	3 	3g011 3Uz2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s4   A1AA1A	A1 A	!A11A58A5c                @   d|z   }t          j        |dd|          }t          |d          5 }t          j        |          5 }t          j        |dd          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t	          j        ||           d S )Nry   r   r   r   rE   r'   rz   r   )re   rd   r}   r|   r   r   )ri   r'   r!   r  rN   r   rw   r  s           r(   r  z(TestExcelFileRead.test_excel_read_buffer_  s5    =QvVVV#t__ 	Na NCsx1MMMN N N N N N N N N N N N N N N	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	h/////s5   A>A'A>'A+	+A>.A+	/A>>BBc                    t          d|z   d          5 }t          j        |          5 }t          j        |dd|           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |j        sJ d S )Nry   rz   r   r   r  )r}   re   r|   rd   closed)ri   r'   r!   r   rt   s        r(   test_reader_closes_filez)TestExcelFileRead.test_reader_closes_filei  s   'H$d++ 	Uqa UDdx1VTTTTU U U U U U U U U U U U U U U	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U
 xs4   A%AA%A	A%A	A%%A),A)c                    d}t          j        d|z             5 }t          j        t          |          5  t          j        |d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nz8Engine should not be specified when passing an ExcelFilery   r   r   rb   )re   r|   r,   r   r   rd   )ri   r!   r   xls       r(   test_conflicting_excel_enginesz0TestExcelFileRead.test_conflicting_excel_enginesq  s    H\'H,-- 	0z555 0 0b////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s4   A1AA1A	A1 A	!A11A58A5c                &   t          j        d|z   |          }t          d|z   d          5 }|                                }d d d            n# 1 swxY w Y   t          j        t	          |          |          }t          j        ||           d S )Nry   rb   rz   )re   rd   r}   r  r   r   r   )ri   r'   r!   rN   r   rB   r  s          r(   test_excel_read_binaryz(TestExcelFileRead.test_excel_read_binaryy  s    =8!3FCCC'H$d++ 	q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 wt}}V<<<
h/////s   AAAc                    t          d|z   d          5 }t          j        ||          }d d d            n# 1 swxY w Y   t          j        d|z   |          }t          j        ||           d S )Nry   rz   rb   )r}   re   rd   r   r   )ri   r!   r'   r   r   rN   s         r(   %test_excel_read_binary_via_read_excelz7TestExcelFileRead.test_excel_read_binary_via_read_excel  s    'H$d++ 	5q]1V444F	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5=8!3FCCC
fh/////s   7;;c                    t          dd          5 }t          j        t          d          5  t	          j        |ddg           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nzdf_header_oob.xlsxrz   zexceeds maximumr   r   r{   ro  )r}   r,   r   r   re   rd   )ri   r'   r   s      r(   )test_read_excel_header_index_out_of_rangez;TestExcelFileRead.test_read_excel_header_index_out_of_range  s    &-- 	0z1BCCC 0 0aA////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s4   A*AA*A	A*A	A**A.1A.r  zdf_empty.xlsxzdf_equals.xlsxc                    t          dgd          }t          j        ddgddg          }t          d	d
gg||d          }t	          j        |dddd	g          }t          j        ||           d S )NZI2r   r5  )r   zB.1I11I12r.  r{   r   rB  )rQ   r   r  r   r   r  )r   r   r  r   re   rd   r   r   )ri   r  r  colsrN   r   s         r(   test_header_with_index_colz,TestExcelFileRead.test_header_with_index_col  s     SE%%%%z<&@PUWWWq!fXS$gNNNQ1v
 
 
 	h/////r*   c                   t          ||           d|z   }t          j        |          5 }t          j        |ddgd|          }d d d            n# 1 swxY w Y   t	          ||          }t          j        ddgd| d	          }t          j        |d d         |dd          g|d                                         |d                                         g
          }	t          g g |	          }
t          j        |
|           d S )Ntest_datetime_mir   r{   )r  rE   r'   z
2020-02-29z
2020-03-01r  r  r  r.  rg  )r\   re   r|   rd   rM   DatetimeIndexr   r/  to_pydatetimer   r   r   )ri   r:   r'   r!   r   rc   r  rT   dtiexpected_column_indexrN   s              r(   test_read_datetime_multiindexz/TestExcelFileRead.test_read_datetime_multiindex  sf   #FG444)\!__ 	U]5!Q1VTTTF	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U Hf--l;====QQQ * 6!Wc!""gA$$&&A$$&&!
 !
 !
 Rr3HIII
h/////s   AAAc                    t          j        t          d          5  t          j        d| dd          5  	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NzValue must be one of *r   zio.excelz.readerabc)r,   r   r   re   rv  r  s     r(   test_engine_invalid_optionz,TestExcelFileRead.test_engine_invalid_option  s    ]:-EFFF 	 	"#?h#?#?#?GG                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s3   AAAA	AA	AA #A c                *   |dk    rt          j        d           |dk    r3|                    t           j                            d                     t          j        d|z             5 }|j        dgk    sJ 	 d d d            d S # 1 swxY w Y   d S )Nr   r  r   r  rW   r  r   )r,   re  rY   rZ   r[   re   r|   sheet_names)ri   r:   r'   r!   rc   s        r(   test_ignore_chartsheetsz)TestExcelFileRead.test_ignore_chartsheets  s    vKDEEEX!!Q "    
 \,122 	3e$
22222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   +BBBc                   t           f}|t          j        d|            n-|dk    rdd l}t           |j        j        f}n|dk    r	ddlm} |f}t          j	        d|           5 }t          |                              dd           t          j        d	          5  	 t          j        ||
           n# |$ r Y nw xY wd d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NzInvalid test for engine=r   r   r   r  corruptzutf-8)encodingFrb   )r
   r,   re  r   biffhr  r    r  r   rh  r   
write_textr  re   r|   )ri   r'   r!   errorsr   r  files          r(   test_corrupt_files_closedz+TestExcelFileRead.test_corrupt_files_closed  s   >K;6;;<<<<vKKK $*"67FFz!!555555#%F_1x1122 	dJJ!!)g!>>>+E22  Lf55555   D              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sZ   '9C( C"B98C9C>C CCC(C	C(C	C((C,/C,N)r  r  r  r  r,   r  rl   r   r  rZ   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r1   r*   r(   r  r    s       7 7 7 V^D!!!3 3 "!3" " "$$0 $0 $0L [[*=*=*=>>0 0 ?>002 2 263 3 3$ [	
QFQFHx&:Xx<PQ 3 3	 30 0 0  0 0 00 0 00 0 00 0 0 [Z/;K)LMM0 0 NM00 0 0*  3 3 3    r*   r  )r!   r"   r#   r$   )r!   r"   r'   rJ   r#   r"   )rN   r   r!   r"   r'   r"   r#   rO   )=
__future__r   r   r   	functoolsr   rA   r   r  pathlibr   r  r   urllib.errorr	   zipfiler
   numpyr   r,   pandas._configr   pandas.compatr   pandas.util._test_decoratorsutil_test_decoratorsr  pandasre   r   r   r   r   r   pandas._testing_testingr   pandas.core.arraysr   r   rZ   r  
pytestmarkr2   r-   r  engine_paramsr)   r/   r  r"   r;   r'   r!   rI   rM   rU   r\   r^   r  r1   r*   r(   <module>r     s'   " " " " " "                    				        				 ! ! ! ! ! !            5 5 5 5 5 5 - - - - - - ) ) ) ) ) ) ) ) )                              
  ('J===
 FLBM&!!
   FLBM*%%
   FLBM&!!
   FLx!8!8999FLmbmE22333FL=2=1B#C#CDDD18   *        	       
   
      2 2 2 2
 
 
\0 \0 \0 \0 \0 \0 \0 \0~(Y Y Y Y Y Y Y Y Y Yr*   