def to_clipboard(obj, excel=True, sep=None, **kwargs):  
encoding = kwargs.pop('<STR_LIT>', '<STR_LIT:utf-8>')<EOL>if encoding is not None and encoding.lower().replace('<STR_LIT:->', '<STR_LIT>') != '<STR_LIT:utf8>':<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>from pandas.io.clipboard import clipboard_set<EOL>if excel is None:<EOL><INDENT>excel = True<EOL><DEDENT>if excel:<EOL><INDENT>try:<EOL><INDENT>if sep is None:<EOL><INDENT>sep = '<STR_LIT:\t>'<EOL><DEDENT>buf = StringIO()<EOL>obj.to_csv(buf, sep=sep, encoding='<STR_LIT:utf-8>', **kwargs)<EOL>text = buf.getvalue()<EOL>clipboard_set(text)<EOL>return<EOL><DEDENT>except TypeError:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>elif sep is not None:<EOL><INDENT>warnings.warn('<STR_LIT>')<EOL><DEDENT>if isinstance(obj, ABCDataFrame):<EOL><INDENT>with option_context('<STR_LIT>', <NUM_LIT>):<EOL><INDENT>objstr = obj.to_string(**kwargs)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>objstr = str(obj)<EOL><DEDENT>clipboard_set(objstr)<EOL>
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 : boolean, 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 gtk or PyQt4 modules)
  - Windows:
  - OS X: