使用剪贴板将Excel数据复制到IPython中的python列表中? [英] Copying excel data into a python list in IPython using clipboard?
本文介绍了使用剪贴板将Excel数据复制到IPython中的python列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法执行以下工作流程:
Is there a way to perform the following workflow:
- 在Excel电子表格中选择单元格
- 使用Ctrl + C复制它们
- 以python列表或numpy数组的形式将选定单元格的内容输入到IPython shell中?
推荐答案
更新:似乎 readline
@PauloAlmeida提到的东西默认在IPython的1.0版本中打开。所以你要做的就是:
Update: It seems that the readline
thing that @PauloAlmeida mentioned is turned on by default in the 1.0 verison of IPython. So all you have to do is:
-
来自numpy import array
- 从电子表格复制单元格
- 点击
Alt + V
而不是Ctrl + V
from numpy import array
- Copy the cells from the spreadsheet
- Hit
Alt+V
instead ofCtrl+V
你会在IPython中获得类似:
And you will get in IPython something like:
array([[1, 1], [2, 2]])
或者您可以使用pandas库 read_clipboard
方法。
Or you can use the pandas library read_clipboard
method.
import pandas as pd
pd.read_clipboard() # If you have selected the headers
pd.read_clipboard(header=None) # If you haven't selected the headers
这将返回一个pandas DataFrame对象,其作用类似于电子表格。您可以在他们的官方文档中找到更多相关信息。
This will return you a pandas DataFrame object which acts similarly to a spreadsheet. You can find more about it in their official documentation.
这篇关于使用剪贴板将Excel数据复制到IPython中的python列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文