「Fault」という名前の列があります。ここには、さまざまなデバイスから抽出された障害コードがあります。 特定の日の障害コードの1つを以下に示します。
"インバーターインバーター20が制限を下回っています:0.96キロワット/インバーター(1.63キロワットの58.9%)2019/11/30 7:30:00 AM(太陽az:123.4 el:3.7)持続時間:4.00時間インバーターインバーター23が制限を下回っています:0.95キロワット/インバーター(1.63キロワットの57.9%)2019年11月30日午前7:30:00(太陽az:123.4 el:3.7)持続時間:3.50時間 "
次の形式で詳細を抽出する必要があります----列名:値
インバーター:20
限界以下(kW /インバーター):0.96
最大の%:58.9%
日付2019年11月30日
時間:7:30:00 AM
Sun Az:123.4
標高:3.7
期間(時間):4
障害コードもある2番目のインバーターがある場合(上記の障害コードの2行目を参照)
インバーター:23
限界以下(kW /インバーター):0.95
最大の%:57.9%
日付2019年11月30日
時間:7:30:00 AM
Sun Az:123.4
標高:3.7
期間(時間):3.50
場合によっては、1行で同様のコードを提供できる5つまたは10のインバーター(70のうち)が存在する可能性があります。
これを行う方法を教えてください。 JSLだけですか?または数式を使用できますか? いずれにせよ-私はいくつかの助けが必要です。
数式エディタを使用して、これについて多くの進歩を遂げることができるはずです-WORD関数を見てください
デイブ、
はい、1つまたは2つの障害のあるインバーターがある場合は可能ですが、たとえば、1つの日付の1行に23の障害コードがある場合は、非常に多くの列を個別に作成してから、それぞれの式を作成する必要があります。 23台のインバーター。 私があなたの解決策を理解しているかどうかを明確にできますか。また、抽出後の分析の目的を要約した別の行を追加しました。
私はこのようなデータを何度も処理しなければなりませんでした。私が取らなければならないと思うアプローチは、入力ファイルからすべてのデータをJMPデータテーブルに読み込むことです。JMPデータテーブルでは、完全な各行が1つの列に読み込まれます。最終的に、1列のデータテーブルが作成され、行数は入力データテーブルの行数と等しくなります。
次に、Label、Value、Lineの3つの列を持つ新しいテーブルを作成します。次に、1つの列の各行の内容をスキャンするJSLを使用して、新しいテーブルに新しい行を作成し、ラベル(つまり、インバーター、制限以下(KW /インバーター)など)、値(つまり、20 、0.96など)および現在の行番号であるLine ..... Row()。また、これがライン上の1番目のインバーター、または2番目のインバーターであることに基づく追加の出力列が必要になる場合があります。
これは、While()関数をWord()関数と組み合わせて使用して、区切り文字として「:」をスキャンすることで実行できます。奇数番号の単語はラベルになり、偶数番号の単語は値になります。
この新しいテーブルが作成されると、Tables => Splitを使用して、インバーターごとに1つの行に簡単に移動できます。
ジム
提案ありがとう。 試してみます。 私はスクリプトを初めて使用するので、例を見て理解します。
余暇があった……まだ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();
)
;
);
);すごい! それは機能します。私の要求を達成するためにこの長いコードを書くことに忍耐強く感謝します。 私はこれを私が持っている他のアラートコードに実装しようとしています。どうもありがとうございました。それは私を何年も救いました。