I'm trying to write a python function with arguments like ranges and sheets. The output i need is a dictionary or other structure. How can i deal with this function's return?
Actually i need to return rows. May be an example with sorting rows and place the result on different sheet is enough.
Thanks.
Last edit: Dani Budinova 2014-08-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, so you can't save a dictionary value in a cell so you need to represent
it somehow. One idea could be to convert the return value to a string
rather a variant in the VBA wrapper function or convert it to a string in
the Python code just before returning the value.
Another idea could be to write a function to "unwrap" the dictionary into a
n x 2 array and then use it in a worksheet as an Excel array formula.
If you describe more precisely what kind of behaviour you'd like, maybe
with some source code snippets, I can try to help you implement what you
need.
Hi Dani,
FYI release v2.0.2 of ExcelPython should deal with dictionary return values gracefully in a worksheet formula - essentially it unpacks them into an n x 2 array.
Please let me know what you think!
Regards,
Eric
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I changed init.py, line 10:
for vname in f.code.co_varnames[:f.code.co_argcount]:
to fix treating local variables as argument.
How can I receive any container type from a python function?
BR,
Dani
Excellent thanks for that.
Can you explain better what you mean by "receive any container type from a python function"?
Last edit: Eric Reynolds 2014-08-07
Hi Eric,
I'm trying to write a python function with arguments like ranges and sheets. The output i need is a dictionary or other structure. How can i deal with this function's return?
Actually i need to return rows. May be an example with sorting rows and place the result on different sheet is enough.
Thanks.
Last edit: Dani Budinova 2014-08-08
Ok, so you can't save a dictionary value in a cell so you need to represent
it somehow. One idea could be to convert the return value to a string
rather a variant in the VBA wrapper function or convert it to a string in
the Python code just before returning the value.
Another idea could be to write a function to "unwrap" the dictionary into a
n x 2 array and then use it in a worksheet as an Excel array formula.
If you describe more precisely what kind of behaviour you'd like, maybe
with some source code snippets, I can try to help you implement what you
need.
Eric.
Thanks Eric!
For now i think that reading some examples and tests will be enough. Can you please provide me a link for them?
Regards,
Dani
Please take a look at the github site, docs folder.
The documentation for v2 is still in progress, over the next few days I
hope to improve on it.
Let me know how you get on!
Hi Dani,
FYI release v2.0.2 of ExcelPython should deal with dictionary return values gracefully in a worksheet formula - essentially it unpacks them into an n x 2 array.
Please let me know what you think!
Regards,
Eric