Home > OS >  "Space" get's lost when I copy-paste from Excel in to Python Shell
"Space" get's lost when I copy-paste from Excel in to Python Shell

Time:06-03

I want to copy/paste following from Excel:

Word1 Word2

When I past it in the Python3.7 Shell it looks like that:

Word1Word2

Can I add something to the "input()" so that it recognize the space/tab that you have when copy cells from Excel?

Yes I know you can import Excel Files but that is not what I need in my script. Thank you

CodePudding user response:

I found this answer in another thread: Copying excel data into a python list in IPython using clipboard?

Basically you use pandas to get the data from the clipboard like so:

import pandas as pd
...
# wait user to copy cells in excel
input() # wait for enter or whatever
cells = pd.read_clipboard() # read content from clipboard
...

This stores the data in a table format. From there you can do whatever with it.

  • Related