【发布时间】:2015-07-23 00:57:54
【问题描述】:
我为 DOORS 9.5 编写了一个脚本,该脚本在 DOORS 模块中查找特定对象并将它们写入 csv 文件。然而,在特定数量的行之后,它停止写入 csv 文件,我只得到了我请求的对象的一半。 我正在使用我在互联网上找到的字符串替换功能。那么这可能是问题所在,还是 dxl 可以在 csv 文件中写入某种最大值?
如果有人能帮我解决这个问题会非常好,因为我在互联网上找不到任何解决方案或理解为什么这不起作用。
// String replacement function
string replace (string sSource, string sSearch, string sReplace)
{
int iLen = length sSource
if (iLen == 0) return ""
int iLenSearch = length(sSearch)
if (iLenSearch == 0)
{
print "search string must not be empty"
return ""
}
// read the first char for latter comparison -> speed optimization
char firstChar = sSearch[0]
Buffer s = create()
int pos = 0, d1,d2;
int i
while (pos < iLen) {
char ch = sSource[pos];
bool found = true
if (ch != firstChar) {pos ++; s+= ch; continue}
for (i = 1; i < iLenSearch; i++)
if (sSource[pos+i] != sSearch[i]) { found = false; break }
if (!found) {pos++; s+= ch; continue}
s += sReplace
pos += iLenSearch
}
string result = stringOf s
delete s
return result
}
Module m = read(modulePath, false)
Object o
string s
string eval
Stream outfile = write("D:\\Python\\Toolbeta\\data\\modules\\test.csv")
for o in m do
{
eval = o."Evaluation Spec Filter"
if(eval == "Evaluation Step Object")
{
s = o."Object Text"
s = replace(s,"\n","\\n")
outfile2 << o."HierarchyNumber" ";" s "\n"
}
}
close outfile
【问题讨论】:
标签: python string csv ibm-doors