
    LMh                        U d dl Z d dlZd dlmZmZmZmZ d dlZd dl	m
Z
 dededej        fdZi dej        d	ej        d
ej        dej        dej        dej        dej        dededededededej        dej        dej        dej        ej        ej        ej        dZeeef         ed<   ddiddidZeeeeeeef         f         f         ed <   d!Zdd"d#eded$edee         deej        eeeef         ej        f         f         f
d%Zd&edee         defd'Zd(ededee         defd)Zd&ed$edefd*ZdS )+    N)AnyCallableOptionalUnion)dataset_download	sql_querypathreturnc                     t          j        |          5 }t          j        | |          }|cd d d            S # 1 swxY w Y   d S N)sqlite3connectpdread_sql_query)r   r	   conndfs       Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/kagglehub/pandas_datasets.pywrapped_read_sql_queryr      s    			 $y$//                 s   9= =z.csv.tsvz.json.jsonlz.xmlz.parquetz.featherz.sqlitez.sqlite3z.dbz.db3z.s3dbz.dl3z.xlsz.xlsxz.xlsmz.xlsb)z.odfz.odsz.odt%SUPPORTED_READ_FUNCTIONS_BY_EXTENSIONsep	linesT)r   r   STATIC_KWARGS_BY_EXTENSIONz/Loading from a SQLite file requires a SQL query)pandas_kwargshandler   c                8   |i n|}t           j                            |          d         }t          ||          }t	          | |          }	  |t          |||          i t          ||          }n'# t          $ r}d| }	t          |	          |d}~ww xY w|S )a  Creates pandas DataFrame(s) from a file in the dataset

    Args:
        handle: (string) The dataset handle
        path: (string) Path to a file within the dataset
        pandas_kwargs:
            (dict) Optional set of kwargs to pass to the pandas `read_*` method while constructing the DataFrame(s)
        sql_query:
            (string) Argument to be used for SQLite files. Required when reading a SQLite file. See pandas documentation
            for details: https://pandas.pydata.org/docs/reference/api/pandas.read_sql_query.html

    Returns:
        - dict[int | str, DataFrame] for Excel-like files with multiple sheets
        - A pandas DataFrame for all others

    Raises:
        ValueError: If the file extension is not supported or the file fails to read
    N   zError reading file: )	osr	   splitext_validate_read_functionr   _build_args_build_kwargs	Exception
ValueError)
r   r	   r   r   file_extensionread_functionfilepathresulteread_error_messages
             r   load_pandas_datasetr-   ;   s    2 (/BB]MW%%d++A.N+NIFFM  --H4)<<
NM::
 
  4 4 47A77+,,!34 Ms   %A3 3
B=BBr'   c                     | t           vrBd|  dd                    t                                                      }t          |          d t           |          }|t          u r|st          t
                    |S )NzUnsupported file extension: 'z"'. Supported file extensions are: z, )r   joinkeysr&   r   MISSING_SQL_QUERY_ERROR_MESSAGE)r'   r   extension_error_messager(   s       r   r"   r"   f   s    BBBhN h h.2ii8]8b8b8d8d.e.eh h 	  011t;9.IM...y.8999    r(   c                 &    | t           k    r|gn||gS r   )r   )r(   r	   r   s      r   r#   r#   u   s    "&<<<D669dBSSr3   c                 >    | t           vri nt           |          }i ||S r   )r   )r'   r   static_kwargss      r   r$   r$   z   s2    $>>>D^_mDn 
 .m-}--r3   ) r    r   typingr   r   r   r   pandasr   kagglehub.datasetsr   str	DataFramer   read_csv	read_jsonread_xmlread_parquetread_feather
read_excelr   dict__annotations__r   boolr1   intr-   r"   listr#   r$    r3   r   <module>rH      s   					  1 1 1 1 1 1 1 1 1 1 1 1     / / / / / /
c      >
BK>
BK> R\> bl	>
 BK> > > %> &> 
!> "> #>  "!>& BM'>( R])>* R]+>, R]->. MMM3> > > %tCM':   : PUVZmhoqugvEwEw Dd3c4i0@+@&A!AB w w w"S  	( ( ((
( 	(
 }( 2<eCHor|;<<=( ( ( (VC HSM h    Tx Ts Tx} TQU T T T T
.# .c .d . . . . . .r3   