ValueError: The name 'Subject identification [Individual/Pool]' already exists in the column collection. Parameter name: value
ValueError: The name 'Subject identification [Individual/Pool]' already exists in the column collection. Parameter name: value
下面的代码返回错误:
我没有发现这个错误 googlying..
import datetime
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import IndexSet, DataValueCursor, RowSelection
from Spotfire.Dxp.Data.DataType import DateTime
dictTable = Document.Data.Tables['Column renaming mapping']
dictionary = dict()
key = 0
value = 0
colNum = 0
cursorKeys = DataValueCursor.CreateFormatted(dictTable.Columns['PDW short name'])
cursorValues = DataValueCursor.CreateFormatted(dictTable.Columns['PDW long name'])
rowCount = dictTable.RowCount
rowsToInclude = IndexSet(rowCount,True)
for row in dictTable.GetRows(rowsToInclude,cursorKeys,cursorValues):
rowIndex = row.Index
key = cursorKeys.CurrentValue
print key
val = cursorValues.CurrentValue
print val
dictionary[key] = val
for table in Document.Data.Tables:
for col in table.Columns:
if col.Name in dictionary:
col.Name = dictionary[key]
我当然做错了。
我的目标是迭代所有 tables 并修改某些列的命名。
我希望根据 table 我调用 discTable.
修改它们
根据代码生成的内容添加完整错误和打印结果。
TSRECID
TS Record ID
STUDYKEY
PDW unique ID
INSERTDT
Record entry date
UPDATEDT
Record update date
AUDITID
Transaction unique ID
SPONSOR
Sponsor
PSMSNAME
Preclinical Study Management System
STUDYID
Study ID
STUDYTITLE
Study title
PROJID
PIMS project ID
PROJDESC
PIMS project description
ETHICPROJ
PIMS ethical project
STUDYCAT
PIMS study category
STUDYTP
PIMS study type
PROTSTATUS
PIMS protocol status
STDPROTID
PIMS standard protocol ID
RATIONALE
Scientific Rationale
PRIMOBJECTIVE
Primary objective
SECOBJECTIVE
Secondary objective
NBSUBJECTS
Number of subjects
SUBLVLID
Subject identification [Individual/Pool]
Traceback (most recent call last):
File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
File "<string>", line 31, in <module>
File "Spotfire.Dxp.Data", line unknown, in set_Name
ValueError: The name 'Subject identification [Individual/Pool]' already exists in the column collection.
Parameter name: value
System.ArgumentException: The name 'Subject identification [Individual/Pool]' already exists in the column collection.
Parameter name: value
at Spotfire.Dxp.Data.DataColumn.set_Name(String value)
at _stub_##25(Closure , CallSite , Object , Object )
at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, CallSite site, Object[] args)
at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at <module>##4(Closure , Scope , LanguageContext )
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)
如果您尝试将列重命名为 table 中已使用的列(给定 table 中的 2 列不能重名),则会出现此错误。我建议弄清楚哪个 table 导致错误并仔细检查是否还没有名为 'Subject identification [Individual/Pool]'
的列
谢谢,亚采克!
下面的代码返回错误: 我没有发现这个错误 googlying..
import datetime
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import IndexSet, DataValueCursor, RowSelection
from Spotfire.Dxp.Data.DataType import DateTime
dictTable = Document.Data.Tables['Column renaming mapping']
dictionary = dict()
key = 0
value = 0
colNum = 0
cursorKeys = DataValueCursor.CreateFormatted(dictTable.Columns['PDW short name'])
cursorValues = DataValueCursor.CreateFormatted(dictTable.Columns['PDW long name'])
rowCount = dictTable.RowCount
rowsToInclude = IndexSet(rowCount,True)
for row in dictTable.GetRows(rowsToInclude,cursorKeys,cursorValues):
rowIndex = row.Index
key = cursorKeys.CurrentValue
print key
val = cursorValues.CurrentValue
print val
dictionary[key] = val
for table in Document.Data.Tables:
for col in table.Columns:
if col.Name in dictionary:
col.Name = dictionary[key]
我当然做错了。 我的目标是迭代所有 tables 并修改某些列的命名。 我希望根据 table 我调用 discTable.
修改它们根据代码生成的内容添加完整错误和打印结果。
TSRECID
TS Record ID
STUDYKEY
PDW unique ID
INSERTDT
Record entry date
UPDATEDT
Record update date
AUDITID
Transaction unique ID
SPONSOR
Sponsor
PSMSNAME
Preclinical Study Management System
STUDYID
Study ID
STUDYTITLE
Study title
PROJID
PIMS project ID
PROJDESC
PIMS project description
ETHICPROJ
PIMS ethical project
STUDYCAT
PIMS study category
STUDYTP
PIMS study type
PROTSTATUS
PIMS protocol status
STDPROTID
PIMS standard protocol ID
RATIONALE
Scientific Rationale
PRIMOBJECTIVE
Primary objective
SECOBJECTIVE
Secondary objective
NBSUBJECTS
Number of subjects
SUBLVLID
Subject identification [Individual/Pool]
Traceback (most recent call last):
File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
File "<string>", line 31, in <module>
File "Spotfire.Dxp.Data", line unknown, in set_Name
ValueError: The name 'Subject identification [Individual/Pool]' already exists in the column collection.
Parameter name: value
System.ArgumentException: The name 'Subject identification [Individual/Pool]' already exists in the column collection.
Parameter name: value
at Spotfire.Dxp.Data.DataColumn.set_Name(String value)
at _stub_##25(Closure , CallSite , Object , Object )
at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, CallSite site, Object[] args)
at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at <module>##4(Closure , Scope , LanguageContext )
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)
如果您尝试将列重命名为 table 中已使用的列(给定 table 中的 2 列不能重名),则会出现此错误。我建议弄清楚哪个 table 导致错误并仔细检查是否还没有名为 'Subject identification [Individual/Pool]'
的列谢谢,亚采克!