Skip to content

Commit 37ce181

Browse files
author
y-p
committed
BUG: read_clipboard decode bytes first (windows)
1 parent 398d89e commit 37ce181

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pandas/io/clipboard.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ def read_clipboard(**kwargs): # pragma: no cover
1818
from pandas.io.parsers import read_table
1919
text = clipboard_get()
2020

21+
# try to decode (if needed on PY3)
22+
# Strange. linux py33 doesn't complain, win py33 does
23+
if compat.PY3:
24+
try:
25+
text = compat.bytes_to_str(
26+
text, encoding=(kwargs.get('encoding') or
27+
get_option('display.encoding'))
28+
)
29+
except:
30+
pass
31+
2132
# Excel copies into clipboard with \t seperation
2233
# inspect no more then the 10 first lines, if they
2334
# all contain an equal number (>0) of tabs, infer
@@ -37,15 +48,6 @@ def read_clipboard(**kwargs): # pragma: no cover
3748
if kwargs.get('sep') is None and kwargs.get('delim_whitespace') is None:
3849
kwargs['sep'] = '\s+'
3950

40-
# try to decode (if needed on PY3)
41-
if compat.PY3:
42-
try:
43-
text = compat.bytes_to_str(
44-
text, encoding=(kwargs.get('encoding') or
45-
get_option('display.encoding'))
46-
)
47-
except:
48-
pass
4951
return read_table(StringIO(text), **kwargs)
5052

5153

0 commit comments

Comments
 (0)