Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of function is given as text value #2

Open
Johanvdberg opened this issue Sep 21, 2020 · 7 comments
Open

Output of function is given as text value #2

Johanvdberg opened this issue Sep 21, 2020 · 7 comments

Comments

@Johanvdberg
Copy link

Johanvdberg commented Sep 21, 2020

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.

@luozhijian
Copy link
Owner

luozhijian commented Sep 22, 2020

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"

@Johanvdberg
Copy link
Author

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.

@luozhijian
Copy link
Owner

Yes. Thanks and good to know it works.

@Johanvdberg
Copy link
Author

I don't know VBA how can I parse {"text/plain": "19.0"} to give 19.0?

@luozhijian
Copy link
Owner

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.

@Johanvdberg
Copy link
Author

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.

@luozhijian
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants