Hi,
I’m using pyscript to run a function from an HTML page that reads an Excel file and returns the value from column two when column one is equal to a text input value on the HTML page. I want to incorporate a second spreadsheet that does the same thing but uses a different text input value (and returns the corresponding value from another column in the second spreadsheet). I seem to be running into problems adding a second spreadsheet to my py-config file. Below is my working code.
.toml
packages = ["pandas","openpyxl"]
[[fetch]]
from="./path/spreadsheet1.xlsx"
.py
import js
import pandas as pd
from pyscript import document
def pytest(event):
test1a=document.querySelector("#test1i")
test1b=test1a.value
df1=pd.read_excel('spreadsheet1.xlsx', sheet_name='sheet1')
test1c=df1.loc[df1['column1']==test1b, 'column2'].values[0]
test1d=document.querySelector("#test1o")
test1d.value=test1c
.html
<HTML>
<head>
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
<py-config src="./test.toml"></py-config>
</head>
<body>
<input name="test1i" id="test1i" />
<input name="test2i" id="test2i" />
<button py-click="pytest">test</button>
<input name="test1o" id="test1o" />
<input name="test2o" id="test2o" />
</body>
<HTML>
How would I modify my code to lookup the value of input “test2i” in another spreadsheet’s first column and return the corresponding value of another column in the second spreadsheet to input “test2o”.
Thanks in advance for any and all help.