idZddlmZddlmZddlmZddlZddlm Z ddl m Z ddl m Z dd lmZdd lmZdd lmZmZerdd lmZe d de jfddZ dddZdS)zio on the clipboard) annotations)StringIO) TYPE_CHECKINGN)lib) set_module)find_stack_level)check_dtype_backend) ABCDataFrame) get_optionoption_context) DtypeBackendpandasz\s+sepstr dtype_backendDtypeBackend | lib.NoDefaultc |dd}|;|dddkrtdt |dd lm}dd lm}|} | | dptd }n#t$rYnwxYw|dd  d dddd}d|D}t|dkrt|dkr|dkrwd}t|dt|ddz } | dkr0|dt#t%| n(t'|t(st+d|dt|dkr| dd|d<nNt|dkr;| ddkr"t-jdt1|t3|f||d|S)a Read text from clipboard and pass to :func:`~pandas.read_csv`. Parses clipboard contents similar to how CSV files are parsed using :func:`~pandas.read_csv`. Parameters ---------- sep : str, default '\\s+' A string or regex delimiter. The default of ``'\\s+'`` denotes one or more whitespace characters. dtype_backend : {'numpy_nullable', 'pyarrow'} Back-end data type applied to the resultant :class:`DataFrame` (still experimental). If not specified, the default behavior is to not use nullable data types. If specified, the behavior is as follows: * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` :class:`DataFrame` .. versionadded:: 2.0 **kwargs See :func:`~pandas.read_csv` for the full argument list. Returns ------- DataFrame A parsed :class:`~pandas.DataFrame` object. See Also -------- DataFrame.to_clipboard : Copy object to the system clipboard. read_csv : Read a comma-separated values (csv) file into DataFrame. read_fwf : Read a table of fixed-width formatted lines into DataFrame. Examples -------- >>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=["A", "B", "C"]) >>> df.to_clipboard() # doctest: +SKIP >>> pd.read_clipboard() # doctest: +SKIP A B C 0 1 2 3 1 4 5 6 encodingutf-8N-utf8z3reading from clipboard only supports utf-8 encodingr) clipboard_get)read_csvzdisplay.encodingi' c^h|]*}|dd+S)  )lstripcount).0xs BC:\PYTHON\_runtimes\venv\Lib\site-packages\pandas/io/clipboards.py z!read_clipboard..ns0 7 7 7Aahhsmm!!$'' 7 7 7r z index_colzsep=z must be a stringenginepythonczIread_clipboard with regex separator does not work properly with c engine. stacklevel)rr)poplowerreplaceNotImplementedErrorr pandas.io.clipboardrpandas.io.parsersrdecodegetr AttributeErrorsplitlenr! setdefaultlistrange isinstancer ValueErrorwarningswarnrr) rrkwargsrrrtextlinescounts index_lengths r%read_clipboardrFsjzz*g..H 0 0 8 8b A AV K K!"WXXX &&&111111****** =??D {{6::j11SZ@R5S5STT       %L  t $ $SbS )#2# .E8 7 7 7 7F 5zzA~~#f++**vzz||q/@/@58}}s58??5+A+A'B'BB 1     k4l0C0C+D+D E E E S ! !53C333444 3xx!|| 8,,4#x SA&**X..#55 W'))    8HTNN S= S SF S SSs:7B22 B?>B?Texcel bool | None str | NonereturnNonec |dd}|;|dddkrtddd lm}|d }|rw |d }t }|j|f|dd ||}||dS#t$r%tj d tYn(wxYw|"tj dtt|tr6tdd5|jdi|}dddn #1swxYwYnt#|}||dS)a Attempt to write text representation of object to the system clipboard The clipboard can be then pasted into Excel for example. Parameters ---------- obj : the object to write to the clipboard excel : bool, defaults to True if True, use the provided separator, writing in a csv format for allowing easy pasting into excel. if False, write a string representation of the object to the clipboard sep : optional, defaults to tab other keywords are passed to to_csv Notes ----- Requirements for your platform - Linux: xclip, or xsel (with PyQt4 modules) - Windows: - OS X: rrNrrrz&clipboard only supports utf-8 encodingr) clipboard_setTr )rrzAto_clipboard in excel mode requires a single character separator.r-z7to_clipboard with excel=False ignores the sep argument.zdisplay.max_colwidth)r/r0r1r>r3rMrto_csvgetvalue TypeErrorr?r@rr=r r to_stringr) objrGrrArrMbufrBobjstrs r% to_clipboardrVs2zz*g..H 0 0 8 8b A AV K KABBB111111 }   {**C CJs @g @ @ @ @ @<<>>D M$    F    MS+--         E'))    #|$$ 2D 9 9 - -"S],,V,,F - - - - - - - - - - - - - - -SM&s%!AB%%,CC D::D>D>)rrrr)TN)rGrHrrIrJrK)__doc__ __future__riortypingrr? pandas._libsrpandas.util._decoratorsrpandas.util._exceptionsrpandas.util._validatorsr pandas.core.dtypes.genericr rr r pandas._typingr no_defaultrFrVrNr'r%rbsZ"""""" ......444444777777333333 ,++++++ H25.jTjTjTjTjT\7;AAAAAAAr'