33from pandas .compat import StringIO
44
55
6- def read_clipboard (** kwargs ): # pragma: no cover
7- """
6+ def read_clipboard (sep = '\s+' , ** kwargs ): # pragma: no cover
7+ r """
88 Read text from clipboard and pass to read_table. See read_table for the
99 full argument list
1010
11- If unspecified, `sep` defaults to '\s+'
11+ Parameters
12+ ----------
13+ sep : str, default '\s+'.
14+ A string or regex delimiter. The default of '\s+' denotes
15+ one or more whitespace characters.
1216
1317 Returns
1418 -------
@@ -29,7 +33,7 @@ def read_clipboard(**kwargs): # pragma: no cover
2933 except :
3034 pass
3135
32- # Excel copies into clipboard with \t seperation
36+ # Excel copies into clipboard with \t separation
3337 # inspect no more then the 10 first lines, if they
3438 # all contain an equal number (>0) of tabs, infer
3539 # that this came from excel and set 'sep' accordingly
@@ -43,12 +47,12 @@ def read_clipboard(**kwargs): # pragma: no cover
4347
4448 counts = set ([x .lstrip ().count ('\t ' ) for x in lines ])
4549 if len (lines ) > 1 and len (counts ) == 1 and counts .pop () != 0 :
46- kwargs [ ' sep' ] = '\t '
50+ sep = '\t '
4751
48- if kwargs . get ( ' sep' ) is None and kwargs .get ('delim_whitespace' ) is None :
49- kwargs [ ' sep' ] = '\s+'
52+ if sep is None and kwargs .get ('delim_whitespace' ) is None :
53+ sep = '\s+'
5054
51- return read_table (StringIO (text ), ** kwargs )
55+ return read_table (StringIO (text ), sep = sep , ** kwargs )
5256
5357
5458def to_clipboard (obj , excel = None , sep = None , ** kwargs ): # pragma: no cover
0 commit comments