You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Spotfire中通过IronPython脚本获取数据连接名称?

用IronPython提取Spotfire数据连接名称

两种可行方案:

1. 从数据表源信息文本提取

你复制的源信息里确实包含Connection name字段,可以通过IronPython解析这段文本拿到名称:

  • 先通过数据表的SourceInformation属性获取完整源信息字符串
  • 用正则表达式匹配提取目标内容,示例代码:
from Spotfire.Dxp.Data import DataTable
import re

# 替换为你要操作的目标数据表,这里以第一个表为例
targetTable = Document.Data.Tables[0]
sourceText = targetTable.SourceInformation

# 匹配Connection name行的内容
matchResult = re.search(r'Connection name:\s*(.*)', sourceText)
if matchResult:
    connName = matchResult.group(1).strip()
    print(f"提取到的连接名称:{connName}")

2. 直接从数据连接对象获取(更可靠)

其实不用解析文本,Spotfire API提供了更直接的方式:如果数据表是从数据连接导入的,可通过DataConnection对象直接读取名称,避免文本格式变化导致的提取失败:

from Spotfire.Dxp.Data import DataTable

targetTable = Document.Data.Tables[0]
if targetTable.DataConnection is not None:
    connName = targetTable.DataConnection.Name
    print(f"数据连接名称:{connName}")

内容的提问来源于stack exchange,提问作者John Munns

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 02:44:52