こんにちは、
テキストファイルから必要なデータを抽出するのは非常に困難です。データは以下のフォーマットの.txtファイル(添付ファイル)であり、大きな(100 Mb)ファイルで繰り返されます。
温度0x100
パートID 0x5A6A111F
5626 0合格DC_VoLevels.4 GPIO_32 312 1.0000 V 3.1638 V 3.3000 V -4.0000 mA 0
サイトソートビン
------------------------------------
0 123 4
私は2つの列と見出しPart IDとBinと以下にリストされているデータでdatテーブルを作成する必要があります:
パートIDビン
0x5A6A111F 4
私は部品IDを引き出すことができますが、以下のBinと番号は私が問題を抱えているものです。任意の助けは非常に高く評価されます。
ジェン
このようにデータをインポートするのは面倒ですが、ファイルを1行ずつ読み込んで、キーワードでデータを処理する方法を決定することで実行できます。詳細は下記の例をご覧ください。
// load the file to be imported as a string
str = Load Text File( "$downloads\SampleFile.jsl" );
// create a table to add to
nt = New Table( "Example",
New Column( "PartID", "Character" ),
New Column( "Bin", "Numeric" )
);
// create a list with strings of each line of data
lines = Words( str, "\!N" );
// loop through each line of the file
for(i=1,i<=nitems(lines),i++,
if( // If the line starts with PART ID,
starts with(lines[i], "PART ID" ),
// it's the start of a new row
nt << add rows(1);
// grab the PartID at the end of the line
nt:PartID = Word( -1, lines[i] );
,
// if it starts with a bunch of dashes
starts with(lines[i], "---" ),
// the next line must contain column values
// so grab them and split them by spaces
colVals = Words( lines[i+1], " " );
// set the Bin column to the value in the third position
nt:Bin = colVals[3];
);
)
このスクリプトは以下のテーブルを作成します。
