3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

記号間の文字列を抽出する(SPSS Modeler データ加工逆引き2-5)

3
Last updated at Posted at 2022-07-01

記号間の文字列を抽出(ハイフンの間の文字列を抽出)

スクリーンショット 2022-06-17 16.44.31.png

1.想定される利用目的

・コード番号から商品や設備の特定
・設備ログから異常検知をするための特定のメッセージの抽出

2.サンプルストリームのダウンロード

3.サンプルストリームの説明

スクリーンショット 2022-06-17 16.47.51.png

a.入力するデータは以下の通りです。
スクリーンショット 2022-06-17 14.43.27.png

b.[フィールド作成]ノードを編集します。[issubstring_count(文字列,N番目の文字列,フィールド)]で2回目に登場する文字列の位置を整数で返します。
スクリーンショット 2022-06-17 16.54.40.png

式ビルダーの文字列関数を利用すると簡単に入力できます。
スクリーンショット 2022-06-17 16.55.15.png

[プレビュー]をします。2度目のハイフンの位置が2レコードとも6文字目だとわかります。
スクリーンショット 2022-06-17 16.58.26.png

c.3番目のハイフンの位置も同じように求めます。
スクリーンショット 2022-06-17 17.01.10.png

[プレビュー]をします。3度目のハイフンの位置が2レコードで異なります。
スクリーンショット 2022-06-17 17.01.30.png

d.[substring(開始位置,文字数,フィールド)]を使って該当する文字列を抽出します。
スクリーンショット 2022-06-17 17.02.01.png

e.[テーブル]を実行します。
スクリーンショット 2022-06-17 17.02.39.png

f.ここまでの処理をひとつのノードでまとめることができます。
スクリーンショット 2022-06-17 17.06.57.png

h.記号が全てハイフンなので、それを区切り文字に指定した方法でも同じ処理が可能です。
スクリーンショット 2022-06-17 17.07.16.png

注意事項

SPSS Modelerバージョンは18.3を利用しました。古いバージョンでは紹介した関数がまだ含まれていない場合がありえます。

4.参考情報

任意の文字列を抽出

よく使う文字列関数

SPSS Modeler ノードリファレンス目次

SPSS Modeler 逆引きストリーム集(データ加工)

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?