텍스트 파일을 병합하여 엑셀 파일로 변환하려고 합니다.
파일을 병합하는 스크립트와 파일을 정리하는 스크립트를 찾았습니다(빈 열 삭제 등).
두 스크립트를 결합하면 다음 메시지가 표시됩니다.
"send는 'send' 액세스 또는 평가에서 스크립팅 가능한 개체를 예상합니다."
스크립트 실패 위치: Set Selected()
누군가 내가 문제를 해결하도록 도와 줄 수 있습니까?
두 가지를 결합한 방법은 다음과 같습니다.
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 );