Dark Knight
Dark Knight

Reputation: 175

Updating a Spotfire table with another temp table

I have a table - update_table_df that contains columns WELL, OIL, GAS . it contains information for 3 WELLS -A,B,C .

i created a temp table that contains new information for 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()

I get this error "TypeError: 'DataColumn' object is not subscriptable" when trying to extract unique well from the first row of the temp table. Any help on how to do this right?

Upvotes: 0

Views: 36

Answers (0)

Related Questions