我有一列“ Fault”(故障)-从各种设备中提取故障代码。 下面给出了某一天的故障代码之一。
“逆变器逆变器20低于限制:0.96千瓦/逆变器(1.63千瓦的58.9%)在11/30/2019 7:30:00 AM(星期日:123.4 el:3.7)持续时间:4.00小时逆变器逆变器23低于限制:0.95千瓦/逆变器(1.63千瓦的57.9%)在11/30/2019 7:30:00 AM(太阳:123.4埃尔:3.7)持续时间:3.50小时“
我需要以以下格式提取详细信息-列名称:值
逆变器:20
低于限制(kW /逆变器):0.96
最大百分比:58.9%
日期11/30/2019
时间:7:30:00 AM
太阳角:123.4
海拔:3.7
持续时间(小时):4
如果第二台逆变器也有故障代码(请参见上面故障代码的第二行)
逆变器:23
低于限制(kW /逆变器):0.95
最大百分比:57.9%
日期11/30/2019
时间:7:30:00 AM
太阳角:123.4
海拔:3.7
持续时间(小时):3.50
有时可能有5或10个逆变器(共70个),它们可以在一行中给出相似的代码。
你能告诉我如何完成这项工作吗? 仅通过JSL吗?还是可以使用公式? 无论哪种方式-我都需要帮助。
您应该可以使用公式编辑器在此方面取得很多进展-看一下WORD函数
戴夫
是的,如果我只有1或2个故障逆变器,那我可以,但是例如,如果我在同一行的一行中有23个故障代码,那么我需要分别创建这么多列,然后为每个23个逆变器。 您能说明我是否了解您的解决方案。我还添加了另一行,总结了提取后分析的目标。
我不得不多次处理这样的数据。我认为必须采取的方法是将所有数据从输入文件中读取到JMP数据表中,在该表中,每一行都被读入单个列中。您将得到一个只有一列的数据表,并且行数等于输入数据表中的行数。
接下来,您将创建一个包含3列的新表,标签,值和行。然后,使用扫描一列中每一行内容的JSL,在新表中创建新行,并填充Label(即Inverter,低于限制(KW / Inverter)等),Value(即20)。 ,0.96等)和Line(行),它们只是当前行号..... Row()。可能还必须有一个附加的输出列,该列基于该线路上的第一台逆变器或第二台逆变器.... etc。
可以使用While()函数结合Word()函数扫描“:”作为定界符来完成此操作。奇数编号的单词将是标签,偶数编号的将是值。
创建此新表后,您可以使用Tables => Split轻松地将每个逆变器移至一行。
吉姆
谢谢您的建议。 我会尝试。 由于我是脚本新手,所以我将通过示例来弄清楚。
我有一些空闲时间...与Covid-19仍然没有其他关系,因此我写了一些JSL,应该为您提供一个良好的入门,以读取数据
Names Default To Here( 1 );
dt = Open(
"Path to the data file",
columns( New Column( "c000001", Character, "Nominal" ) ),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 0 ),
Column Names Start( 1 ),
Data Starts( 1 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
);
// Create the new output data table
dtLong = New Table( "Long Data",
New Column( "Label", character ),
New Column( "Value", character ),
New Column( "Line" ),
New Column( "Instance" )
);
// A function that returns the next word in the line and
// then removes the word from the front of the target line
getWord = Function( {},
theWord = Trim( Word( 1, target, " " ) );
target = Trim( Substr( target, Length( theWord ) + 1 ) );
theWord;
);
// Loop through all rows in the input data table
For( i = 1, i <= N Rows( dt ), i++,
instance = 0;
target = Column( dt, 1 )[i];
While( Word( 1, target, " " ) != "",
dtLong << add rows( 1 );
dtLong:line[N Rows( dtLong )] = i;
theWord = getWord();
Match( theWord,
"inverter",
instance++;
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:Label[N Rows( dtLong )] = theWord;
theWord = getWord();
theWord = getword();
dtLong:value[N Rows( dtLong )] = theWord;,
"below",
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:Label[N Rows( dtLong )] = theWord || " limit (KW/Inverter)";
theWord = getWord();
theWord = getWord();
dtLong:value[N Rows( dtLong )] = theWord;
// Get the % of Max
dtLong << Add Rows( 1 );
dtLong:line[N Rows( dtLong )] = i;
dtLong:Instance[N Rows( dtLong )] = instance;
theWord = getWord();
theWord = getWord();
dtLong:Label[N Rows( dtLong )] = "% of Max";
dtLong:value[N Rows( dtLong )] = Substr( theWord, 2 );
// Skip forward to the Date
For( k = 1, k <= 5, k++,
theWord = getWord()
);
// Get the Date
dtLong << add rows( 1 );
theWord = getWord();
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:line[N Rows( dtLong )] = i;
dtLong:Label[N Rows( dtLong )] = "Date";
dtLong:value[N Rows( dtLong )] = theWord;
// Get the Time
dtLong << add rows( 1 );
theWord = getWord();
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:line[N Rows( dtLong )] = i;
dtLong:Label[N Rows( dtLong )] = "Time";
dtLong:value[N Rows( dtLong )] = theWord || getWord();
// Get the Sun Az
dtLong << add rows( 1 );
theWord = getWord();
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:line[N Rows( dtLong )] = i;
dtLong:Label[N Rows( dtLong )] = Substr( theWord, 2 ) || " " || getWord();
dtLong:value[N Rows( dtLong )] = getWord();
// Get the Elevation
dtLong << add rows( 1 );
theWord = getWord();
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:line[N Rows( dtLong )] = i;
dtLong:Label[N Rows( dtLong )] = "Elevation";
dtLong:value[N Rows( dtLong )] = Word( -1, getWord(), ")" );,
"Duration:",
dtLong:Instance[N Rows( dtLong )] = instance;
dtLong:Label[N Rows( dtLong )] = theWord || " (hrs)";
dtLong:value[N Rows( dtLong )] = getWord();
theWord = getWord();
)
;
);
);惊人的! 它的工作原理。感谢您耐心编写此长代码以完成我的请求。 我正在尝试将其实现到我拥有的其他Alert代码。非常感谢。它为我节省了很多时间。