From 51b133c6e0f300e687f14135aff193a25effc10a Mon Sep 17 00:00:00 2001 From: Makarov Andrey Date: Mon, 25 Jan 2016 09:55:39 +0300 Subject: [PATCH] Use system line terminator in to_clipboard by default Adds line_terminator optional argument to to_clipboard --- pandas/io/clipboard.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/io/clipboard.py b/pandas/io/clipboard.py index 2109e1c5d6d4c..f893402f21f95 100644 --- a/pandas/io/clipboard.py +++ b/pandas/io/clipboard.py @@ -51,7 +51,7 @@ def read_clipboard(**kwargs): # pragma: no cover return read_table(StringIO(text), **kwargs) -def to_clipboard(obj, excel=None, sep=None, **kwargs): # pragma: no cover +def to_clipboard(obj, excel=None, sep=None, line_terminator=None, **kwargs): # pragma: no cover """ Attempt to write text representation of object to the system clipboard The clipboard can be then pasted into Excel for example. @@ -65,6 +65,7 @@ def to_clipboard(obj, excel=None, sep=None, **kwargs): # pragma: no cover if False, write a string representation of the object to the clipboard sep : optional, defaults to tab + line_terminator : optional, defaults to system line terminator other keywords are passed to to_csv Notes @@ -82,8 +83,11 @@ def to_clipboard(obj, excel=None, sep=None, **kwargs): # pragma: no cover try: if sep is None: sep = '\t' + if line_terminator is None: + import os + line_terminator = os.linesep buf = StringIO() - obj.to_csv(buf, sep=sep, **kwargs) + obj.to_csv(buf, sep=sep, line_terminator=line_terminator, **kwargs) clipboard_set(buf.getvalue()) return except: