Excel to Python I/O structure retriever
Project description
An Excel (XL) 2 Python (Py) structure retriever for optimization. Convert the I/O of XL files into Python.
Description
Convert an XL structure to Py and use any minimization algorithm of your will
The current project makes use of the XL COM interface (win32com library) to:
Read an objective function cell
- Recursively build its dependent structure as of its formula
The XL structure is represented in Py as a dict() object
- The structure is referenced to as:
dictobj[Workbook number as int][Worksheet number as int][Row as int][Column as int]
Support for multi-XL workbook/worksheet references
Support for single worksheet multirange retrieval
XL cell formulas are translated to evaluable strings, which reference the already converted XL structure in Py
- The calculation structure is determinded by cell-dependency trees, which have been already stored during the conversion (2)
Support for circular references
Ongoing development: A simple evolutionary algorithm that runs based off the abovementioned structure.
Features
Conversion Library
The following XL functions can be currently handled by xl2py. xl2py is capable of undertaking single-cells, arrays and array/matrix operations
Standard operators: +, -, /, *, ^
Logical operators: <, >, <=, >=, <>, =
IF
AVERAGE
STDEV.P
TRANSPOSE
ABS
MMULT
IFERROR
SUM
COUNT
SQRT
On the way
RPN (reverse-polish notation) handling of formulas
Object oriented formulas (no more evals)
Instructions
Installation
pip install xl2py==version_no
Example: I/O object creation
import xl2py Builder = xl2py.builder() # creates a xl2py builder object # place the path of your XL file path = r'C:\\User\\DEFAULT\\WHATEVER\\...' # define your XL file password (if it exists) pwd = 'password' # opens up a XL COM interface and attach it to the Builder object Builder.connect_com(path,pwd) # declare your input cell/range references inputs = xl2py.xlref(<Workbook str or int>, \ <Worksheet int>, <A1- or R1C1-type XL references>) # inputs include other inputs to the xlref object inputs += xl2py.xlref(<str or int>, <int>, <str>) # output must be a single cell reference output = xl2py.xlref(<str or int>, <int>, <str>) # Now you are all set. You shall translate the XL structure to python. Builder.set_structure(inputs,output) # If you want to change the input cell/range values... # vals must be of the shape of the inputs # and must be parsed as a list of lists or numpy arrays Builder.set_input_values(vals) # grab the output (objective fun) value as numpy array output_val = Builder.get_output_value() # Grab the new output value
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file xl2py-1.0.4b.zip
.
File metadata
- Download URL: xl2py-1.0.4b.zip
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3f8274173a8e26a69ebe51cbd3e82d4d184579e7f748c287e34a66cbc5ca5bf |
|
MD5 | d64133f295bac7244701f1748cf9cb15 |
|
BLAKE2b-256 | 8b5d77797e951b31a5877343f646a002efd92d830273296eff1ee524b4496de8 |