Is it possible to fetch the tabular data copied from Excel into a list, tuple or dictionary using python?
The data will contain multiple rows and columns, such as range A1:B10, therefore the python array should contain row and column index information as well
Asked
Active
Viewed 1,330 times
1
alwbtc
- 25,815
- 57
- 129
- 182
2 Answers
0
I recommend you to save the file as csv and use numpy.genfromtxt
For instance
import numpy as np
data = np.genfromtxt("G:/mydata.csv", delimiter=',', dtype=object)
Choose your params accordingly. From an array you can easily convert to anything you like. If you know, that you have doubles all over, you can set dtype=np.float forthwith.
embert
- 6,902
- 8
- 47
- 78
-
I just copy a range from an Excel table. Can python access this tabular data in the clipboard? – alwbtc Jan 15 '14 at 12:35
-
@alwbtc Didn't read your question carefully. Check out [this thread](http://stackoverflow.com/questions/101128/how-do-i-read-text-from-the-windows-clipboard-from-python) – embert Jan 15 '14 at 12:38
0
There are some libraries can help you read data from Excel files in Python.
miaodadao
- 329
- 1
- 2
- 12
-
Thanks, but I don't want to read a file. I just want to get the clipboard data into a python array. – alwbtc Jan 15 '14 at 12:37