python - 在 Python/IronPython 中包含现有代码片段
问题描述
我想在 TIBCO Spotfire 中将以下代码包含到我的 IronPython/Python 脚本中。有人对此有解决方案吗?我是 IronPython/Python 和 Spotfire 的初学者。提前谢谢了!
问候菲利克斯
{
var table = application.Document.Data.Tables.DefaultTableReference;
var sourceView = table.GenerateSourceView();
Func<StringBuilder, DataOperation, string, int> dumpOperationInfoRecursively = null;
dumpOperationInfoRecursively = (stringBuilder, operation, indentationSpaces) =>
{
int step = 1;
// If the operation had any inputs, then first print the first input's information.
if (operation.Inputs.Count > 0)
{
step = dumpOperationInfoRecursively(stringBuilder, operation.Inputs[0], indentationSpaces);
step++;
}
// Print information about this operation.
stringBuilder.AppendFormat("{0}{1}. {2}\r\n", indentationSpaces, step, operation.DisplayName);
// Output names of any transformations we have.
IList<DataTransformation> transformations = new List<DataTransformation>();
var ost = sourceView.OperationsSupportingTransformations.FirstOrDefault(op => op.DataOperation == operation);
if (ost != null)
{
transformations = ost.GetTransformations();
}
int index = 0;
foreach (var transformation in transformations)
{
stringBuilder.AppendFormat("{0}{1}. {2}\r\n", indentationSpaces + " ", Convert.ToChar('a' + index), transformation.Name);
index++;
}
// Last, print information about additional inputs. (Typically the
// additional data for an Add Rows or Add Columns operation.)
for (int i = 1; i < operation.Inputs.Count; ++i)
{
dumpOperationInfoRecursively(stringBuilder, operation.Inputs[i], indentationSpaces + " ");
}
// Returns the step number for this operation.
return step;
};
var sb = new StringBuilder();
dumpOperationInfoRecursively(sb, sourceView.LastOperation, string.Empty);
return sb.ToString();
}
解决方案
正如 Oliver 所说,这不是 python,所以你不能在 Spotfire 中将它导入 IronPython。如果要达到相同的结果,则需要编写具有相同功能的 python 脚本。也就是说,这看起来像是您正在尝试重写 Concatenate() 函数,尽管它不是很清楚,而且我不确定您打算将什么用作输入或您打算将输出放在哪里。你想通过导入这个来完成什么?正如我所提到的,看起来答案是“使用 Concatentate()”,但我认为如果这不是您想要的,我们需要更多信息。
推荐阅读
- python - 在 padas 数据框中写入类似 json 的数据
- python - 如何为 Pyomo 设置类似于 GAMS 的循环索引
- azure-devops - 在 Terraform 中,如何在 Terraform 计划阶段加入字符串?
- spring - @DataJpaTest 加载 KafkaConfiguration 并且测试失败
- arrays - 解释 HTML 响应并粘贴到工作表上的最佳方法
- homebrew - 卸载 Homebrew
- python-3.x - 模仿 Excel 输出的 Python 3 Pandas 数据透视表
- flutter - 是否可以在 Flutter 上以应用购买调试模式运行?
- memory - 写入闪存 dspic33e
- python - 我可以让 Python 将昵称列表与全名列表进行比较吗?