3
3
from pandas .compat import StringIO
4
4
5
5
6
- def read_clipboard (** kwargs ): # pragma: no cover
7
- """
6
+ def read_clipboard (sep = '\s+' , ** kwargs ): # pragma: no cover
7
+ r """
8
8
Read text from clipboard and pass to read_table. See read_table for the
9
9
full argument list
10
10
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.
12
16
13
17
Returns
14
18
-------
@@ -29,7 +33,7 @@ def read_clipboard(**kwargs): # pragma: no cover
29
33
except :
30
34
pass
31
35
32
- # Excel copies into clipboard with \t seperation
36
+ # Excel copies into clipboard with \t separation
33
37
# inspect no more then the 10 first lines, if they
34
38
# all contain an equal number (>0) of tabs, infer
35
39
# that this came from excel and set 'sep' accordingly
@@ -43,12 +47,12 @@ def read_clipboard(**kwargs): # pragma: no cover
43
47
44
48
counts = set ([x .lstrip ().count ('\t ' ) for x in lines ])
45
49
if len (lines ) > 1 and len (counts ) == 1 and counts .pop () != 0 :
46
- kwargs [ ' sep' ] = '\t '
50
+ sep = '\t '
47
51
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+'
50
54
51
- return read_table (StringIO (text ), ** kwargs )
55
+ return read_table (StringIO (text ), sep = sep , ** kwargs )
52
56
53
57
54
58
def to_clipboard (obj , excel = None , sep = None , ** kwargs ): # pragma: no cover
0 commit comments