API: default export for to_clipboard is now csv/tsv suitable for excel (GH3368) by jreback · Pull Request #5070 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation23 Commits1 Checks0 Files changed

Conversation

This file contains hidden or 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

[ Show hidden characters]({{ revealButtonHref }})

jreback

@jtratner

We should have a setting io.clipboard.sep . Can we change to \t for windows/osx by default and I guess ',' for Linux? (set the defaults in config_init, right?)

@ghost

to_clipboard()'s current behaviour is useful for other things, how about df.to_clipboard(excel=False)?

@jtratner

@jreback excel=False is fine, but that'd just be a synonym for sep=',' right?

@jreback

I think we make \t the default, maybe make it a config option as well? io.clip.sep?

@jreback

@y-p I will update docs/announcemnt not sure an explicity excel kw is necessary

@ghost

df.to_clip() can be used to paste a nicely-formatted textual table into a document, that's useful as well.
Not sure making an arg for method invocation into a config option makes sense.

@jreback

@y-p I actually need to use a sep of ',' to paste as I copy from a linux X window to excel; prob not typical

@jreback

there is no easy way to actually form the object prior to writing to the clipboad; eg. we are using to_csv and not to_string.

@ghost

right. I thought it'd be best if to_clip(excel=False) kept the current behaviour, and to_clip(1)
generated a csv.

@jreback

@jreback

jreback added a commit that referenced this pull request

Oct 16, 2013

@jreback

API: default export for to_clipboard is now csv (GH3368)

@ghost

What a bummer to be ignored like that. sadness.

@jreback

@y-p what do you mean? I never saw a comment when I posted a request for further comments...

@ghost

Isn't it clearly better to extend the existing functionality rather then replace it? I made
that point 3 times early on.
It's totally fine you don't agree, but, what's the reasoning?

@jreback

this doesn't actually change much, except for replacing space separation with tabs sep, which appears to be more compatible with various systems. I believe you pointed out the issue, which tab sep fixes, or is this not the case?

@ghost

tabs allow you to paste into excel, yeah, but now you can't get an aligned textual table into the clipboard.
sep=' ' doesn't replicate the old behavior, try it.

@jreback

and how would you propose for an API to handle both of these somewhat discordant cases?

as IMHO I would think pasting to excel is much more important

@ghost

What's wrong with what I suggested above?:

def to_clipboard(excel=False): if not excel: to_string() # -> clip, original behavior else: to_csv(sep='\t') # -> clip , new behavior

Also, why decide which is more important when it's so easy to allow both while
avoiding breakage to existing behaviour at the same time?

@jreback

ok....that's reasonable....guess I misunderstood what you meant....would have have a problem with default excel=True? it breaks compat, but I think is more intuitive

@ghost

I guess there's not much harm in changing the default,since it's easy
to request the old behavior. It's for interactive use only anyway. so yeah, should be fine.

@jtratner

+1 on excel=True as the default, if for no other reason that it'd be a
whizbang feature to show off. Also, I've spent most of the day
copy/pasting into Excel so that's something.

@jreback

@ghost

Thanks jeff, it's just right now. :)

@jreback

This was referenced

Nov 23, 2013

@ghost ghost mentioned this pull request

Feb 2, 2014

2 participants

@jreback @jtratner