
    h                    *   S SK Jr  S SKrS SKJr  S SKJr  S SKJrJ	r	  S SK
Jr  S SKJrJr  S SKJrJr  S S	KJr  \R(                  " \5         S S
KJr  SSS5        \(       a  S SKJr  S SKJr  S SKJrJrJr   " S S5      r g! , (       d  f       N6= f)    )annotationsN)Sequence)TYPE_CHECKING)_process_null_valuesnormalize_filepath)wrap_df)N_INFER_DEFAULTparse_into_dtype)parse_columns_argparse_row_index_args)_update_columns)PyBatchedCsv)Path)	DataFrame)CsvEncodingPolarsDataType
SchemaDictc                      \ rS rSrSrSSSSSSSSSSSSS\S	SS
SSSSSSSSSSS.                                                         SS jjrSS jrSrg)BatchedCsvReader   zRead a CSV file in batches.TN,"r   FiP  utf8
)
has_headercolumns	separatorcomment_prefix
quote_char	skip_rows
skip_linesschema_overridesnull_valuesmissing_utf8_is_empty_stringignore_errorstry_parse_dates	n_threadsinfer_schema_length
batch_sizen_rowsencoding
low_memoryrechunkskip_rows_after_headerrow_index_namerow_index_offseteol_charnew_columnsraise_if_emptytruncate_ragged_linesdecimal_commac          	     :   [        USS9nS nS nU	bs  [        U	[        5      (       a9  / nU	R                  5        H"  u  n n!UR	                  U [        U!5      45        M$     O%[        U	[        5      (       a  U	nOSn"[        U"5      e[        U
5      n#[        U5      u  n$n[        R                  " S 0 SU_SU_SU_SU_SU_S	U_S
U_SU$_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU#_SU_SU_SU_S[        UU5      _SU_SU_SU_SU_6U l        UU l        g )!NF)check_not_directoryz-`schema_overrides` arg should be list or dictr(   
chunk_sizer   r%   r*   r    r!   
projectionr   r-   r   r+   r'   pathr"   overwrite_dtype_slicer,   r   r   r#   r$   r&   r.   	row_indexr1   r3   r4   r5    )r   
isinstancedictitemsappendr
   r   	TypeErrorr   r   r   newr   _readerr2   )%selfsourcer   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r:   
dtype_listdtype_slicekvmsgprocessed_null_valuesr9   s%                                        V/home/james-whalen/.local/lib/python3.13/site-packages/polars/io/csv/batched_reader.py__init__BatchedCsvReader.__init__   s   @ "&eDBF
7;'*D11
,224DAq%%q*:1*=&>? 5,h77.En$ 4[ A/8
G#'' 
 3
!
 "
 (	

 
  
 "
 "
  
 
 
 
  
 
 (
  #.!
" "#
$ *%
& "'
( .)
* *F+
, ,-
. $:/
0 +>;KL1
2 3
4 *5
6 #87
8 (9
< '    c                   U R                   R                  U5      =nb]  U R                  (       a0  U Vs/ s H"  n[        [	        U5      U R                  5      PM$     sn$ U Vs/ s H  n[	        U5      PM     sn$ gs  snf s  snf )a  
Read `n` batches from the reader.

These batches will be parallelized over the available threads.

Parameters
----------
n
    Number of chunks to fetch; ideally this is >= number of threads.

Examples
--------
>>> reader = pl.read_csv_batched(
...     "./pdsh/tables_scale_100/lineitem.tbl",
...     separator="|",
...     try_parse_dates=True,
... )  # doctest: +SKIP
>>> reader.next_batches(5)  # doctest: +SKIP

Returns
-------
list of DataFrames
N)rD   next_batchesr2   r   r   )rE   nbatchesdfs       rM   rR   BatchedCsvReader.next_batcheso   s|    0 ||0033G@MTMTrOGBK1A1ABW  /66gg66 7s   )A=$B)rD   r2   ):rF   z
str | Pathr   boolr   z$Sequence[int] | Sequence[str] | Noner   strr   
str | Noner   rY   r    intr!   rZ   r"   z,SchemaDict | Sequence[PolarsDataType] | Noner#   z+str | Sequence[str] | dict[str, str] | Noner$   rW   r%   rW   r&   rW   r'   
int | Noner(   r[   r)   rZ   r*   r[   r+   r   r,   rW   r-   rW   r.   rZ   r/   rY   r0   rZ   r1   rX   r2   zSequence[str] | Noner3   rW   r4   rW   r5   rW   returnNone)rS   rZ   r\   zlist[DataFrame] | None)	__name__
__module____qualname____firstlineno____doc__r	   rN   rR   __static_attributes__r=   rP   rM   r   r      s   %  8<%)!$IMCG-2# % $*9 ! & &'%) !,0#&+#=P'P' 	P'
 6P' P' #P' P' P' P' GP' AP' '+P' P' P'  !P'" (#P'$ %P'& 'P'( )P'* +P', -P'. !$/P'0 #1P'2 3P'4 5P'6 *7P'8 9P':  $;P'< =P'> 
?P'drP   r   )!
__future__r   
contextlibcollections.abcr   typingr   polars._utils.variousr   r   polars._utils.wrapr   polars.datatypesr	   r
   polars.io._utilsr   r   polars.io.csv._utilsr   suppressImportErrorpolars._plrr   pathlibr   polarsr   polars._typingr   r   r   r   r=   rP   rM   <module>rs      s`    "  $   ' > D 0%( &  FFt t &%s   B
B