【发布时间】:2019-04-04 10:08:05
【问题描述】:
我有一个 csv 文件,其中包含一些数据,例如:
374,Test Comment multiplelines \n Here's the 2nd line,Other_Data
其中 374 是来自门的对象 ID,然后是一些评论,然后是一些其他数据。 我有一段代码从 CSV 文件中读取数据,将其存储在适当的变量中,然后将其写入门对象。
Module Openend_module = edit("path_to_mod", true,true,true)
Object o ;
Column c;
string attrib;
string oneLine ;
string OBJECT_ID = "";
string Comment = "";
String Other_data = "";
int offset;
string split_text(string s)
{
if (findPlainText(s, sub, offset, len, false))
{
return s[0 : offset -1]
}
else
{
return ""
}
}
Stream input = read("Path_to_Input.txt");
input >> oneLine
OBJECT_ID = split_text(oneLine)
oneLine = oneLine[offset+1:]
Comment = split_text(oneLine)
Other_data = oneLine[offset+1:]
使用print Comment 时,DXL 控制台中的输出为:Test Comment multiplelines \n Here's the 2nd line
for o in Opened_Module do
{
if (o."Absolute Number"""==OBJECT_ID ){
attrib = "Result_Comment " 2
o.attrib = Comment
}
}
但是写入到doors对象之后,\n没有被考虑进去,结果如下:
我尝试将字符串放入缓冲区并使用stringOf(),但转义字符就消失了。
我也尝试在输入的 csv 文本中添加 \r\n 和 \\n,但仍然没有运气
【问题讨论】:
标签: ibm-doors