使用另一个临时表更新 Spotfire 表

问题描述 投票:0回答:1

我有一个表 - update_table_df 其中包含列 WELL, OIL, GAS 。它包含 3 个井 -A、B、C 的信息。

我创建了一个临时表,其中包含 WELL C 的新信息。

from Spotfire.Dxp.Data import DataTable

# Define the names of the tables
table_a_name = "test_output_df"
temp_table_name = "temp"

# Get references to the tables
table_a = Document.Data.Tables[table_a_name]
temp_table = Document.Data.Tables[temp_table_name]

# Extract the unique "WELL" value from the first row of TEMP table
well_value_to_delete = temp_table.Columns["WELL"][0].Value

# Delete rows in TABLE A where "WELL" matches the value from TEMP table
rows_to_delete = [row for row in table_a.GetRows() if row["WELL"] == well_value_to_delete]
for row in rows_to_delete:
    table_a.RemoveRows([row.Id])

# Append rows from TEMP table to TABLE A
for temp_row in temp_table.GetRows():
    table_a.AddRow(temp_row)

# Refresh the visualization to reflect the changes
Document.ActivePageReference.Visuals.Refresh()

尝试从临时表的第一行中提取唯一的井时,出现此错误“TypeError:'DataColumn'对象不可下标”。有关如何正确执行此操作的任何帮助吗?

python ironpython spotfire tibco
1个回答
0
投票

您遇到的错误表明您正在尝试在 DataColumn 对象上使用下标表示法(方括号 []),但这是不受支持的。相反,您应该以不同的方式访问该列的值。

您可以从 TEMP 表的第一行中提取唯一的“WELL”值。

像这样:

well_value_to_delete = temp_table.Columns["WELL"].RowValues[0]
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.