gL idZddlmZddlmZddlmZddlZddlm Z ddl m Z ddl m Z dd lmZdd lmZmZerdd lmZd e j*f dd Z d ddZy)z io on the clipboard ) annotations)StringIO) TYPE_CHECKINGN)lib)find_stack_level)check_dtype_backend) ABCDataFrame) get_optionoption_context) DtypeBackend\s+c |jdd}|.|jjdddk7r tdt |dd lm}dd lm}|} |j|jdxs td }|dd jd dddd}|Dchc]"}|jdjd$} }t!|dkDrxt!| dk(rj| jdk7rWd}t!|dt!|djdz } | dk7r$|j#dt%t'| ||jdd}t!|dkDr|jdd|d<nAt!|dkDr3|jddk(rt)j*dt-|t/|f||d|S#t$rYiwxYwcc}w)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'}, default 'numpy_nullable' Back-end data type applied to the resultant :class:`DataFrame` (still experimental). Behaviour is as follows: * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` (default). * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 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'   z index_coldelim_whitespacer enginepythonczIread_clipboard with regex separator does not work properly with c engine. stacklevel)sep dtype_backend)poplowerreplaceNotImplementedErrorrpandas.io.clipboardrpandas.io.parsersrdecodegetr AttributeErrorsplitlstripcountlen setdefaultlistrangewarningswarnrr) r#r$kwargsrrrtextlinesxcounts index_lengths Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/io/clipboards.pyread_clipboardr>sfzz*g.H 0 8 8b AV K!"WXX &1* ?D {{6::j1SZ@R5ST %L  t $Sb )#2 .E27 7Aahhsm!!$' 7F 7 5zA~#f+*vzz|q/@58}s58??5+A'BB 1    k4l0C+D E {vzz"45= 3x!| 8,4#x SA&**X.#5 W') HTN S= SF SSM    8s"-G,-'G<, G98G9c h|jdd}|.|jjdddk7r tddd lm}|d }|r> |d }t }|j|f|dd ||j}||y|tjdtt|tr(tdd5|j di|}dddn t#|}|y#t$r"tjd tYvwxYw#1swY@xYw)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)r#rzAto_clipboard in excel mode requires a single character separator.r!z7to_clipboard with excel=False ignores the sep argument.zdisplay.max_colwidth)r%r&r' ValueErrorr)r@rto_csvgetvalue TypeErrorr5r6r isinstancer r to_stringstr) objexcelr#r7rr@bufr8objstrs r= to_clipboardrMs42zz*g.H 0 8 8b AV KABB1 }  {*C CJJs @g @ @<<>D $    E') #|$ 2D 9 -"S]],V,F - -S&#  MMS+-   - -srMrAr=r\s{" 473 +25..jT jT/jT\7;AA)3A Ar[