Output of function is given as text value
Johanvdberg opened this issue · 7 comments
Hallo
running the example I get the output of the sum function is
{'text/plain': '19.0'}
the value is is correct but cannot convert the result to a number. When the example notebook is used the result is correct but when a local notebook is used I get the error.
Is it should be {"text/plain": "19.0"}? double quote instead of single quote.
If this case, you can use json.loads('{"text/plain": "19.0"}' )['text/plain']) to get the result.
I am sometimes thinking remove "text/plain", and return only 19.0. With "text/plain", it also make the parsing in Excel VBA difficult. If remove "text/plain", I cannot return an error message string if there is an exception in the function. Please let me know if you have good suggestions.
I am not sure what it means "When the example notebook is used the result is correct but when a local notebook is used I get the error"
The part " When the example... " part was not correct I just tested gain, and yes double quotes.
The Excel VBA function FromJupyter
can do the conversion to 19.0 or an alternatively a new function that call FromJupyter
and do the conversion.
Yes. Thanks and good to know it works.
I don't know VBA how can I parse {"text/plain": "19.0"}
to give 19.0?
Can you let me know which language do you use to call? I can change {"text/plain": "19.0"} to string "19.0", but it cannot be double 19.0 because it is a web call, it can return string.
Currently I am using, Python, Excel and Jupyter.
The idea Python/Jupyter to get data from Excel and save results in Excel, where the data is further processed in Excel. My difficulty is on the side of Excel to transform {"text/plain": "19.0"} to a form I can do arithmetic operations on.
Have you try https://www.xlwings.org/ xlwings. In xlwings, it can call python directly in same computer. I used it and like it. The only disadvantage is that it takes sometimes to start the python in first action, after that, it works great.