New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): Add read_clipboard
and DataFrame.write_clipboard
#15272
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15272 +/- ##
==========================================
+ Coverage 81.32% 81.34% +0.01%
==========================================
Files 1359 1365 +6
Lines 176076 176655 +579
Branches 2526 2526
==========================================
+ Hits 143191 143694 +503
- Misses 32402 32478 +76
Partials 483 483 ☔ View full report in Codecov by Sentry. |
I am not convinced by this one. Two things I am concerned about.
|
I'm not kinda familiar with this. I hope I did the right thing. I use my mac and
About default separator, while copying data in Excel, Google Sheet or WPS, the data will be transformed into csv with separator |
Adding to @CanglongCl 's, rendered html table is another source of clipboard I/O which defaults to tab separator. "I/O of tsv strings via clipboard" is the force of nature, I think. |
Alright. Let's give this a try. I understand why this can be nice. Thank you @CanglongCl |
Closes #9902
Similar to
pandas.DataFrame.to_clipboard
andpandas.read_clipboard
,read_clipboard
reads csv format text from clipboard and convert it intoDataFrame
whereasDataFrame.write_clipboard
writesDataFrame
into clipboard with csv format.These 2 methods are useful while exploring data from Excel or other similar software in interactive environment like jupyter notebook.
Implementation
read_clipboard
just reads the clipboard then passes the result toread_csv
with default separator'\t'
.write_clipboard
just gets csv string by callingDataFrame.write_csv
(but with default separator'\t'
) and writes to clipboard.Difference from
pandas
methodpandas.read_clipboard
uses regex'\\s+'
as separator, butpolars
does not allow regex as separator inread_csv
.Compatibility
Tested Compatible:
Others
Both methods are only tested on M1 macOS. It would be much appreciated if someone could test on Linux and Windows.