What I need to know is, can I get Python to read a spreadsheet (preferably Microsoft Excel), then parse the information and input it into an equation?
It's for a horse-racing program, where the information for several horses will be in one excel spreadsheet, in different rows or columns. I need to know if I can run a calculation for each of those horses separately and then calculate a score for the given horse.
My suggestion is:
csv
comma separated value file, which is a plain text format and much easier to work with. csv
module to work with the data in csv format. You can work with Excel files directly in Python (Excel 2003 format supported via the third party modules xlwt, xlrd ) but this is much harder than working with CSV.
OpenPyXL (“用于读取/写入Excel 2007 xlsx / xlsm文件的Python库”)具有非常好的Pythonic API。
Use xlrd
package. It's on PyPI , so you can just easy_install xlrd
You can export the spreadsheet as a .csv and read it in as a text file, then process it. I have a niggling feeling there might even a CSV parsing python library.
AFAIK there isn't a .xls parser, although I might be wrong.
EDIT: I was wrong: http://www.python-excel.org/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.