
    Mh$                        S r SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
Jr  SSKJr  \R                  R!                  S5      r\R                  R%                  S5      r\\R                  R)                  S	\" \" S
5      5      S
/5      S 5       5       r\S 5       r\S 5       r\R                  R)                  SSS	S/0\
" / SQ/ SQ// SQS94SSS/S.\
" / SQ// SQS94SSSS/S.\
" SS//SS /S94/5      \S! 5       5       r\S" 5       r\R                  R)                  S#S$/ S%Q/ S&Q/4S'/ S(Q/ S)Q/4S*/ S+Q/ S,Q/4/5      \S- 5       5       r\\R                  R)                  S./ S/Q5      S0 5       5       r\S1 5       r\\R                  R)                  S20 \
" S3SS4/05      4SS5/S6.\
" S5SS4/05      4/5      S7 5       5       r\S8 5       r \S9 5       r!\S: 5       r"\S; 5       r#\S< 5       r$g)=zj
Tests that skipped rows are properly handled during
parsing for all of the parsers defined in parsers.py
    )datetime)StringION)EmptyDataError)	DataFrameIndexpyarrow_xfailz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningskiprows   c           	      .   U nSnUR                  [        U5      US SSS9n[        [        SSS5      [        SSS5      [        SSS5      /SS	9n[	        [
        R                  " S
S5      R                  S5      / SQUS9n[        R                  " XF5        g )Nzr#foo,a,b,c
#foo,a,b,c
#foo,a,b,c
#foo,a,b,c
#foo,a,b,c
#foo,a,b,c
1/1/2000,1.,2.,3.
1/2/2000,4,5,6
1/3/2000,7,8,9
r   Tr	   header	index_colparse_dates           name      ?      $@r   r   r   r   r   columnsindex
read_csvr   r   r   r   nparangereshapetmassert_frame_equal)all_parsersr	   parsertextresultr   expecteds          V/var/www/html/env/lib/python3.13/site-packages/pandas/tests/io/parser/test_skiprows.pytest_skip_rows_bugr*      s     F	D __$!QU  F 	$1	xa3XdAq5IJQRE 
		#t$$V,iuH &+    c                 $   U nSSR                  [        S5       Vs/ s H8  nSR                  [        U5      [        US-   5      [        US-   5      /5      PM:     sn5      -   nSSR                  S Vs/ s H8  nSR                  [        U5      [        US-   5      [        US-   5      /5      PM:     sn5      -   nUR                  [	        U5      SS	/S
9nUR                  [	        U5      5      n[
        R                  " XV5        g s  snf s  snf )Nza,b,c


   ,r   r   )r   r   r   r      r
      	   r
   r1   r	   )joinrangestrr   r   r"   r#   )r$   r%   idatacondensed_datar'   condensed_results          r)   test_deep_skip_rowsr;   6   s     Ftyy=B2YGY3q63q1u:s1q5z2	3YG D =UV=U3q63q1u:s1q5z2	3=UV" N __Xd^q!f_=Fx'?@&3 	H 	Ws   ?D
4?D
c           	      .   U nSnUR                  [        U5      SS SSS9n[        [        SSS5      [        SSS5      [        SSS	5      /SS
9n[	        [
        R                  " SS5      R                  S5      / SQUS9n[        R                  " X55        g )Nz^#foo,a,b,c
#foo,a,b,c

#foo,a,b,c
#foo,a,b,c

1/1/2000,1.,2.,3.
1/2/2000,4,5,6
1/3/2000,7,8,9
r
   r   Tr   r   r   r   r   r   r   r   r   r   r   r   )r$   r%   r&   r8   r   r(   s         r)   test_skip_rows_blankr=   F   s     F	D ??41$  D 	$1	xa3XdAq5IJQRE 
		#t$$V,iuH $)r+   zdata,kwargs,expectedzKid,text,num_lines
1,"line 11
line 12",2
2,"line 21
line 22",2
3,"line 31",1r   )r   zline 21
line 22r   )r   zline 31r   idr&   	num_linesr   z+a,b,c
~a
 b~,~e
 d~,~f
 f~
1,2,~12
 13
 14~~r   )	quotecharr	   )za
 bze
 dzf
 f)abczdText,url
~example
 sentence
 one~,url1
~example
 sentence
 two~,url2
~example
 sentence
 three~,url3r   zexample
 sentence
 twourl2Texturlc                 l    U nUR                   " [        U5      40 UD6n[        R                  " XS5        g )Nr   r   r"   r#   )r$   r8   kwargsr(   r%   r'   s         r)   test_skip_row_with_newlinerM   a   s/    H F__Xd^6v6F&+r+   c                     U nSn/ SQ/ SQ/n[        U/ SQS9nUR                  [        U5      S/S9n[        R                  " XT5        g )NzYid,text,num_lines
1,"line '11' line 12",2
2,"line '21' line 22",2
3,"line '31' line 32",1)r   zline '21' line 22r   )r   zline '31' line 32r   r>   rA   r   r3   r   r   r   r"   r#   )r$   r%   r8   exp_datar(   r'   s         r)   test_skip_row_with_quoterQ      sP     FD
 ,-HIH+FGH__Xd^qc_:F&+r+   zdata,exp_dataz\id,text,num_lines
1,"line 
'11' line 12",2
2,"line 
'21' line 22",2
3,"line 
'31' line 32",1)r   zline 
'21' line 22r   )r   zline 
'31' line 32r   z\id,text,num_lines
1,"line '11
' line 12",2
2,"line '21
' line 22",2
3,"line '31
' line 32",1)r   zline '21
' line 22r   )r   zline '31
' line 32r   zbid,text,num_lines
1,"line '11
' 	line 12",2
2,"line '21
' 	line 22",2
3,"line '31
' 	line 32",1)r   zline '21
' 	line 22r   )r   zline '31
' 	line 32r   c                     U nUR                  [        U5      S/S9n[        U/ SQS9n[        R                  " XE5        g )Nr   r3   r>   rA   r   r   r   r"   r#   )r$   r8   rP   r%   r'   r(   s         r)   $test_skip_row_with_newline_and_quoterT      s<    : F__Xd^qc_:F+FGH&+r+   lineterminator)r-   z
c                    U nSR                  / SQ5      n[        / SQ/ SQ/ SQ// SQS9nUR                  S:X  a4  US	:X  a.  [        R                  R                  S
S9nUR                  U5        UR                  SU5      nSn[        R                  " [        USS9   UR                  [        U5      SS/ SQS9nS S S 5        [        R                  " WU5        g ! , (       d  f       N&= f)Nr-   )zSMOSMANIA ThetaProbe-ML2X z2007/01/01 01:00   0.2140 U M z2007/01/01 02:00   0.2141 M O z2007/01/01 04:00   0.2142 D M )
2007/01/01z01:00g1Zd?UM)rX   z02:00gk	g?rZ   O)rX   z04:00gBfj?DrZ   )datetimevarflagoflagrA   pythonrV   z+'CR' not respect with the Python parser yet)reasonz;The 'delim_whitespace' keyword in pd.read_csv is deprecatedF)matchcheck_stacklevelr   T)r	   delim_whitespacenames)r4   r   enginepytestmarkxfailapplymarkerreplacer"   assert_produces_warningFutureWarningr   r   r#   )	r$   rU   requestr%   r8   r(   rj   depr_msgr'   s	            r)   test_skiprows_lineterminatorrr      s     F99	
D 555	

 9H }} ^t%;{{  (U VD!<<n-DLH		#	#X
 TN!:	 ! 

 &(+
 
s   C
C)c                     U nSn[        SS/05      nUR                  [        U5      SS9n[        R                  " XC5        g )Nz	a"
b"
a
1rD   r   r   r3   rO   r$   r%   r8   r(   r'   s        r)   test_skiprows_infield_quoteru      sB     FD#s$H__Xd^a_8F&+r+   zkwargs,expected1   foo)r   rg   c                 v    U nSnUR                   " [        U5      4SS 0UD6n[        R                  " XR5        g )Na
1
2
3
4
5r	   c                     U S-  S:H  $ )Nr   r    xs    r)   <lambda>)test_skip_rows_callable.<locals>.<lambda>   s    A
r+   rK   )r$   rL   r(   r%   r8   r'   s         r)   test_skip_rows_callabler      s9     FD__Xd^U6JUfUF&+r+   c                     U nSn[        SS/SS//5      nUR                  [        U5      S S S9n[        R                  " XC5        g )Nz0,a
1,b
2,c
3,d
4,er   rE   r   dc                     U S;  $ )N)r   r   r|   r}   s    r)   r   0test_skip_rows_callable_not_in.<locals>.<lambda>  s    r+   )r   r	   rO   rt   s        r)   test_skip_rows_callable_not_inr     sR    F$D1c(QH-.H__t.G  F &+r+   c                     U nSnSn[         R                  " [        US9   UR                  [	        U5      S S9  S S S 5        g ! , (       d  f       g = f)Nrz   zNo columns to parse from filerd   c                     g)NTr|   r}   s    r)   r   )test_skip_rows_skip_all.<locals>.<lambda>  s    4r+   r3   )ri   raisesr   r   r   )r$   r%   r8   msgs       r)   test_skip_rows_skip_allr     s?    FD
)C	~S	1@ 
2	1	1   A
Ac                     SnU nSn[         R                  " [        US9   UR                  [	        U5      S S9  S S S 5        g ! , (       d  f       g = f)Nzby zerorz   r   c                     SS-  $ )Nr   r   r|   r}   s    r)   r   -test_skip_rows_bad_callable.<locals>.<lambda>!  s    1q5r+   r3   )ri   r   ZeroDivisionErrorr   r   )r$   r   r%   r8   s       r)   test_skip_rows_bad_callabler     s@    
CFD	(	4A 
5	4	4r   c                     SnU nUR                  [        U5      S/ SQS9n[        / SQ/ SQS.5      n[        R                  " X45        g )Nz$a,b
1,a
2,b
3,c
4,d
5,e
6,f
7,g
8,h
rw   )r   r0   r
   )nrowsr	   )r   r   rw      r1   )rD   rF   egh)rD   rE   rS   )r$   r8   r%   r'   r(   s        r)   test_skip_rows_and_n_rowsr   $  sF    	D F__Xd^1y_IF5NOPH&+r+   c                    SnU nUR                  [        U5      US SS9n[        U5      n[        U5      n[        R                  " U[        S/ SQ05      5        [        R                  " U[        S/ SQ0/ SQS	95        g )
Nz%col_a
10
20
30
40
50
60
70
80
90
100
c                     U S;   $ )N)r   r0   rw   r|   r}   s    r)   r   ,test_skip_rows_with_chunks.<locals>.<lambda>H  s    !y.r+   r0   )rh   r	   	chunksizecol_a)      <   F   )P   Z   d   )r0   rw   r
   )r   )r   r   nextr"   r#   r   )r$   r8   r%   readerdf1df2s         r)   test_skip_rows_with_chunksr   7  s}    D F__v0HTU  F v,C
v,C#y'3C)DEF#y'=)ASTr+   )%__doc__r   ior   numpyr   ri   pandas.errorsr   pandasr   r   pandas._testing_testingr"   rj   usefixturesxfail_pyarrowfilterwarnings
pytestmarkparametrizelistr5   r*   r;   r=   rM   rQ   rT   rr   ru   r   r   r   r   r   r   r|   r+   r)   <module>r      s  
     ( ''8[[''C

 d58na%89, : ,4 4 4 * *4  !+->?3	
 AA3/23_M	
3
 Aq622F;<vuoV		
' B , C D, , ,  +,IJ	
 +,IJ	
! /0QR	
4 , 56, *$, $,N , , 	YaV}%&	()UQFO*DE, , , , A A B B , ,$ U Ur+   