I read the user manual, and I just don’t get what read_fct
and write_fct
expect for parameters and what format they are supposed to return (for write_fct
, I don’t even know what to return).
I wrote read_fct
to send back a list of tuples I pulled from the Data Base, the data I want to look at, and with write_fct
I don’t know what to do.
Could you please give a little example to explain how it’s supposed to work?
thank you for your help
regards
Here is an example of code you can use to understand how it works:
from taipy.config import Config
def read_data(path):
return pd.read_csv(path)
def write_data(data, path):
pd.DataFrame(data).to_csv(path)
generic_data_node_cfg = Config.configure_generic_data_node(id="my_data_node",
read_fct=read_data,
write_fct=write_data,
read_fct_params=["res.csv"],
write_fct_params=["res.csv"])
You also have to be aware of your types. The task function receives the type given by read_data
. The type returned by the task function should be correct for write_data
to work.
In other words, this line of code below should work with "foo" and "bar" optional and function()
, your normal Python function used by your task.
write_data(function(read_data("foo")), "bar")
You can also find the documentation here for more explanation.