o
    ;DiM                     @   sj   d dl mZmZmZ d dlZd dlZd dlmZ d dlm	Z	 dd Z
dddZG d	d
 d
e	Zdd ZdS )    )divisionprint_functionabsolute_importN)izip_longest)Tablec                 C   s   | d u rt  } t| }|S N)localegetpreferredencodingcodecslookup)encodingcodec r   E/var/www/Datamplify/venv/lib/python3.10/site-packages/petl/io/base.pygetcodec   s   
r   c                 C   s   t | ||dS )a  View a sequence of columns as a table, e.g.::

        >>> import petl as etl
        >>> cols = [[0, 1, 2], ['a', 'b', 'c']]
        >>> tbl = etl.fromcolumns(cols)
        >>> tbl
        +----+-----+
        | f0 | f1  |
        +====+=====+
        |  0 | 'a' |
        +----+-----+
        |  1 | 'b' |
        +----+-----+
        |  2 | 'c' |
        +----+-----+

    If columns are not the same length, values will be padded to the length
    of the longest column with `missing`, which is None by default, e.g.::

        >>> cols = [[0, 1, 2], ['a', 'b']]
        >>> tbl = etl.fromcolumns(cols, missing='NA')
        >>> tbl
        +----+------+
        | f0 | f1   |
        +====+======+
        |  0 | 'a'  |
        +----+------+
        |  1 | 'b'  |
        +----+------+
        |  2 | 'NA' |
        +----+------+

    See also :func:`petl.io.json.fromdicts`.

    .. versionadded:: 1.1.0

    )headermissing)ColumnsViewcolsr   r   r   r   r   fromcolumns   s   'r   c                   @   s   e Zd ZdddZdd ZdS )r   Nc                 C   s   || _ || _|| _d S r   r   )selfr   r   r   r   r   r   __init__?   s   
zColumnsView.__init__c                 C   s   t | j| j| jS r   )itercolumnsr   r   r   )r   r   r   r   __iter__D   s   zColumnsView.__iter__NN)__name__
__module____qualname__r   r   r   r   r   r   r   =   s    
r   c                 c   sN    |d u rdd t t| D }t|V  t| i t|dD ]}|V  qd S )Nc                 S   s   g | ]}d | qS )zf%sr   ).0ir   r   r   
<listcomp>J   s    zitercolumns.<locals>.<listcomp>)	fillvalue)rangelentupler   dict)r   r   r   rowr   r   r   r   H   s   
r   r   )
__future__r   r   r   r   r
   petl.compatr   petl.util.baser   r   r   r   r   r   r   r   r   <module>   s   
*