テキストファイルをマージしてExcelファイルに変換しようとしています。
ファイルをマージするスクリプトと、それを消去するスクリプト(空の列などを削除する)を見つけました。
2 つのスクリプトを組み合わせると、次のメッセージが表示されます。
"send は、'send' のアクセスまたは評価でスクリプト可能なオブジェクトを想定しています"
スクリプトは失敗します: Set Selected()
誰かが問題を解決するのを手伝ってくれませんか。
これが私が2つを組み合わせた方法です:
names default to here (1);
Clear Symbols();
//set up variables with starting values
filelist={}; //empty list
//launch dialog to get the file location
(
prefilepath = munger(Pick Directory( "Browse to the Directory of the .txt / .csv files " ),1,"/","");
filepath = Convert File Path( prefilepath, Windows );
prefilelist = Files In Directory( filepath );
n2=nitems(prefilelist);
//filter out any non-txt or csv files
For( i2 = 1, n2 >= i2, i2++,
file=(prefilelist[i2]);
// changed from item 2 to item -1
If( Item( -1, prefilelist[i2], "." ) == "txt" | Item( -1, prefilelist[i2], "." ) == "csv",
Insert Into( filelist,file),
show(file)
)
);
/*
//filter out any non-Excel files for the file list. Commented out
For( i2 = 1, n2 >= i2, i2++,
file=(prefilelist[i2]);
If( Item( -1, prefilelist[i2], "." ) == "xls" | Item( -1, prefilelist[i2], "." ) == "xlsx",
Insert Into( filelist,file),
show(file)
)
);
*/
nf=nitems(filelist); //number of items in the working list
cctable= New Table( "Combined data table ");//make an empty table
cctable<<NEW column=""> 0|
Contains(:WLD Filename, "----") > 0|
Contains(:WLD Filename,"Reprocess Started:")|
Contains(:WLD Filename,"Reprocess Completed:")|
Contains(:WLD Filename,"Comments:")
);
If(ANY(Rows_to_delete) == 1,
DT_Import << Delete Rows(Rows_to_delete);
);
//Find locations of misaligned headers for cleanup
Row_Clip = DT_Import << Get rows where(Contains(:WLD Filename, "WLD Filename") > 0);
//If cleanup needed, continue to concatenation of displaced headers
If(N Rows(Row_Clip) > 0,
//Add End Row to Row List
End_Row = N Rows(DT_Import);
Row_Clip_End = VConcat(Row_Clip,End_Row);
Total_Clips = N Rows(Row_Clip)+1;
//Create invisible repair table from initial rows
DT_Import << Select Rows(Index(1, Row_Clip[1]));
DT_Wafer = DT_Import << Subset( Selected Rows , Output Table Name(TableName||"_Repair"), invisible);
DT_Import << Clear Select;
DT_Wafer << select where(Contains(:WLD Filename, "WLD Filename") > 0);
DCheck = DT_Wafer << Get selected rows;
If(ANY(DCheck) == 1,
DT_Wafer << Delete Rows;
);
DT_Wafer << Begin Data Update;
//Concatenation Loop
For (n=1, n < Total_Clips, n++,
DT_Import << Select Rows(Index(Row_Clip[n], Row_Clip_End[n+1]));
DT_temp = DT_import << Subset(Selected Rows, invisible, Output Table("Temp"));
DT_Import << Clear Select;
For (i=1, i < N Cols()+1, i++,
col = Column(i);
col << Set Name("Col"||Char(i));
);
For (j=1, j < N Cols()+1, j++,
col = Column(j);
col << Set Name(col[1]);
);
DT_temp << select rows (1);
DCheck = DT_temp << Get selected rows;
If(ANY(DCheck) == 1,
DT_temp << delete rows;
);
DT_temp << select where(Contains(:WLD Filename, "WLD Filename") > 0);
DCheck = DT_temp << Get selected rows;
If(ANY(DCheck) == 1,
DT_temp << delete rows;
);
Data Table(TableName||"_Repair") << Concatenate(Data Table("Temp"), invisible, Append to first table);
Close("Temp");
Cleanup_Processing=Round(100*(n+1)/(Total_Clips),1);
wait(0);
Completion_Monitor << Bring Window to Front;
);
DT_Wafer << End Data Update;
//Close(DT_Import);
//If no Cleanup needed
,DT_Wafer = DT_Import;
Cleanup_Processing=100;
);
//Remove any of the unnamed import artifact columns with no data
CName = DT_Wafer << Get Column Names();
CCount = N Items(CName);
for(i=1,i<=CCount,i++,
CTest = Column(CName[i]);
If(Contains(CName[i],"Col") > 0 & Is Missing(CTest[1]),
CName[i]<<SET selected=""></SET></NEW>
添付のスクリプトは元のスクリプトです (私は書きませんでした)。
コードの簡単なスキャン...... CName[i] が << Set Selected の列として解釈されていないと思います。Column() 関数を使用して、列参照であることを確実に示します。
Column(CName[i]) << Set Selected( 1 );