I wrote a script which updates some fields in a database via an API.
fields = [{
"fieldId": "101",
"fieldValues": [{"value": df["A"].item()}]},
{
"fieldId": "102",
"fieldValues": [{"value": df["B"].item()}]},
{
"fieldId": "103",
"fieldValues": [{"value": df["C"].item()}]},
{
"fieldId": "104",
"fieldValues": [{"value": df["D"].item()}]},
{
"fieldId": "105",
"fieldValues": [{"value": df["E"].item()}]
}]
Afterwards I do something like update = update_object(fields = fields)
to update the fields
I’d like to create fields
more dynamically, meaning that a specific fieldId/fieldValues is only part of fields
if (e.g.) df["E"] is not null.
How can I realize that?
2
Answers
Maybe something like this?
prints
and then
prints
This would be a nice case for a list comprehension! In your case, you could use something like this: