![](/img/trans.png)
[英]Python & MSSQL: Python Code to Delete All Rows of Data in MSSQL Table
[英]Delete all rows on spotfire Data Table Iron python
我正在尋找一種方法來刪除我在SPOTFIRE上的數據表中的行,我找不到合適的方法來做到這一點。
我試圖編寫一個腳本來執行它,但它太慢了,我有更多的20k行要刪除。
有人知道為什么它太慢而且還有另一種方法(更快的方式)
from Spotfire.Dxp.Data import RowSelection
table=Document.Data.Tables["my Table name"]
i=0
for row in table.GetRows():
i+=1
rowToDelete=Document.Data.Tables["my Table name"].Select("[index]="+`i`).AsIndexSet()
Document.Data.Tables["my Table name"].RemoveRows(RowSelection(rowToDelete))
我發現了一種更簡單的方法。
from Spotfire.Dxp.Data import RowSelection, IndexSet
dtTarget = Document.Data.Tables["my Table name"]
dtTarget.RemoveRows(RowSelection(IndexSet(dtTarget.RowCount,True)))
以下是從表中刪除所選(標記)行的代碼。
from Spotfire.Dxp.Data import RowSelection
DataTable = Document.Data.Tables['NodeCollection']
# selectedNodes - Name of the marking given in spotfire.
SelectedRows = Document.Data.Markings['selectedNodes'].GetSelection(DataTable)
CollectionTable.RemoveRows(SelectedRows)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.