-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1eaff3
commit 82f717b
Showing
10 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import annotations | ||
|
||
import contextlib | ||
from io import StringIO | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from polars.io.csv.functions import read_csv | ||
|
||
with contextlib.suppress(ImportError): | ||
from polars.polars import read_clipboard_string as _read_clipboard_string | ||
|
||
if TYPE_CHECKING: | ||
from polars import DataFrame | ||
|
||
|
||
def read_clipboard(separator: str = "\t", **kwargs: Any) -> DataFrame: | ||
""" | ||
Read text from clipboard and pass to `read_csv`. | ||
Useful for reading data copied from Excel or other similar spreadsheet software. | ||
Parameters | ||
---------- | ||
separator | ||
Single byte character to use as separator parsing csv from clipboard. | ||
kwargs | ||
Additional arguments passed to `read_csv`. | ||
See Also | ||
-------- | ||
read_csv : Read a csv file into a DataFrame. | ||
DataFrame.write_clipboard : Write a DataFrame to the clipboard. | ||
""" | ||
csv_string: str = _read_clipboard_string() | ||
io_string = StringIO(csv_string) | ||
return read_csv(source=io_string, separator=separator, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters