Skip to content

BUG: read_clipboard() on excel shifts values to the wrong column when there are nulls in the first column #41108

Closed
@saucoide

Description

@saucoide
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

copy this text, or data from excel/libreoffice with the same shape

col1	col2
1	red
	blue
2	green
In [3]: pandas.read_clipboard()
Out[3]: 
   col1   col2
0     1    red
1  blue   None
2     2  green

Problem description

Using read_clipboard() on excel data when there are null values on the first few rows of the first columns causes pandas to use the default separator instead of the "\t" used for excel.

The result is the values shift into the wrong column

Expected Output

In [4]: pandas.read_clipboard()
Out[4]: 
	col1	col2
0	1.0	red
1	NaN	blue
2	2.0	green

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 2cb9652
python : 3.9.3.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.11-zen1-1-zen
Version : #1 ZEN SMP PREEMPT Tue, 30 Mar 2021 14:10:21 +0000
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.utf8
LOCALE : en_US.UTF-8

pandas : 1.2.4
numpy : 1.20.2
pytz : 2021.1
dateutil : 2.8.1
pip : 20.3.3
setuptools : 49.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions