HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/io/excel/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/io/excel/__pycache__/_util.cpython-36.pyc
3

���h��@stddlmZddlmZmZiZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�ZdS)�)�import_optional_dependency)�
is_integer�is_list_likecCs"t|�std��|j}|t|<dS)z�
    Add engine to the excel writer registry.io.excel.

    You must use this method to integrate with ``to_excel``.

    Parameters
    ----------
    klass : ExcelWriter
    z&Can only register callables as enginesN)�callable�
ValueErrorZengine�_writers)�klass�engine_name�r
�7/tmp/pip-build-5_djhm0z/pandas/pandas/io/excel/_util.py�register_writers
rcCs0ddddd�}tdddd�}|r(d|d	<||S)
z�
    Return the default writer for the given extension.

    Parameters
    ----------
    ext : str
        The excel file extension for which to get the default engine.

    Returns
    -------
    str
        The default engine for the extension.
    ZopenpyxlZxlwtZodf)�xlsxZxlsmZxlsZods�
xlsxwriterF�warn)Zraise_on_missingZ
on_versionr
)r)�extZ_default_writersrr
r
r�_get_default_writersrcCsByt|Stk
r<}ztd|�d��|�WYdd}~XnXdS)NzNo Excel writer '�')r�KeyErrorr)r	�errr
r
r�
get_writer4srcCshd}xZ|j�j�D]J}t|�}|td�ks6|td�krDtd|����|d|td�d}qW|dS)ai
    Convert Excel column name like 'AB' to 0-based column index.

    Parameters
    ----------
    x : str
        The Excel column name to convert to a 0-based column index.

    Returns
    -------
    num : int
        The column index corresponding to the name.

    Raises
    ------
    ValueError
        Part of the Excel column name was invalid.
    r�A�ZzInvalid column name: ��)�upper�strip�ordr)�x�index�c�cpr
r
r�
_excel2num;sr!cCsbg}xX|jd�D]J}d|krL|jd�}|jtt|d�t|d�d��q|jt|��qW|S)a�
    Convert comma separated list of column names and ranges to indices.

    Parameters
    ----------
    areas : str
        A string containing a sequence of column ranges (or areas).

    Returns
    -------
    cols : list
        A list of 0-based column indices.

    Examples
    --------
    >>> _range2cols('A:E')
    [0, 1, 2, 3, 4]
    >>> _range2cols('A,C,Z:AB')
    [0, 2, 25, 26, 27]
    �,�:rr)�split�extend�ranger!�append)Zareas�cols�rngr
r
r�_range2cols[s
&r*cCs2|dkr|St|�rtd��t|t�r.t|�S|S)a
    Convert `usecols` into a compatible format for parsing in `parsers.py`.

    Parameters
    ----------
    usecols : object
        The use-columns object to potentially convert.

    Returns
    -------
    converted : object
        The compatible format of `usecols`.
    Nz}Passing an integer for `usecols` is no longer supported.  Please pass in a list of int from 0 to `usecols` inclusive instead.)rr�
isinstance�strr*)Zusecolsr
r
r�_maybe_convert_usecols|s
r-cCs6|dk	r2t|�dkr*tdd�|D��r*dStd��dS)N�css|]}t|t�VqdS)N)r+�int)�.0�itemr
r
r�	<genexpr>�sz)_validate_freeze_panes.<locals>.<genexpr>TzLfreeze_panes must be of form (row, column) where row and column are integersF)�len�allr)Zfreeze_panesr
r
r�_validate_freeze_panes�sr5cCs:x4t|�dkr4|ddks&|ddkr4|dd�}qW|S)Nr�r)r3)�rowr
r
r�_trim_excel_header�s&r8cCsj|d}xXtdt|��D]F}||s,||}||dksD||dkrN|||<qd||<||}qW||fS)a�
    Forward fill blank entries in row but only inside the same parent index.

    Used for creating headers in Multiindex.

    Parameters
    ----------
    row : list
        List of items in a single row.
    control_row : list of bool
        Helps to determine if particular column is in same parent index as the
        previous value. Used to stop propagation of empty cells between
        different indexes.

    Returns
    -------
    Returns changed row and control_row
    rrr6NF)r&r3)r7Zcontrol_row�last�ir
r
r�_fill_mi_header�s
r;cCsRt|�s|nt|�}||}|dkr(dn|}||d|�dg||dd�fS)a�
    Pop the header name for MultiIndex parsing.

    Parameters
    ----------
    row : list
        The data row to parse for the header name.
    index_col : int, list
        The index columns for our data. Assumed to be non-null.

    Returns
    -------
    header_name : str
        The extracted header name.
    trimmed_row : list
        The original data row with the header name removed.
    r6Nr)r�max)r7Z	index_colr:�header_namer
r
r�_pop_header_name�sr>N)Zpandas.compat._optionalrZpandas.core.dtypes.commonrrrrrrr!r*r-r5r8r;r>r
r
r
r�<module>s !!