我正在运行一个脚本,该脚本最初会打开一个数据表。然后,它运行一个For循环,以从CSV打开后续的数据表,并将它们连接到第一个数据表。当我观看脚本运行时,它可以正常工作并将所有行添加到第一个数据表中,但是在脚本结尾时,它将删除许多后面的列,最后只有519行。我无法弄清楚为什么此后的行被删除。任何帮助都太棒了!请参见下面的代码:
//Initiates data table to hold all the data
data = New Table( "3DMark_All Loops" );
//Choose folder containing all .zip files
directory = Pick Directory();
subDir = directory || "All Loops/";
Create Directory(subDir); //create a new sub directory
TheFileList = Files In Directory(directory); //zip files
nFiles = N Items(TheFileList); //get number of zip files in directory
For( i = 1, i < 21, i++,
//open the zip folder and create a list of the files inside
za = Open( directory || zipFolder, zip );
dirlist = za << dir;
Show( dirlist ); // see all contents of zipped folder;
//choose the file from the file list called "Monitoring.csv" and save it in the subdirectory "All Loops" as the Loop Number
For(j = 1, j <= N Items( dirlist ), j++,
file = dirlist[j];
If( Left(file, 3) == "Mon",
text = za << read( file );
current = Save Text File( char(subDir) || char(i) || ".csv", text );
);
);
//Open the .csv file that was just created in the subdirectory
dt_temp = Open(current);
//Select Column 1 and Convert Text to Columns using a ; delimiter
Column(dt_temp, 1) << Set Selected;
dt_temp << Text To Columns(
delimiter( ";" ),
columns(1)
);
//Delete column 1 (which is empty)
dt_temp << Delete Columns(1);
//Create a new column called Loop Number
New Column( "Loop Number", Numeric, Continuous );
//Fill in the loop number for all cells of this column
colLengthTemp = N Rows(dt_temp);
LoopNumber = {};
For (s = 1, s <= colLengthTemp, s++,
LoopNumber[s] = i;
);
:"Loop Number" << Set Values(LoopNumber);
//Concatenate this loops data to the master data table
data << Concatenate( dt_temp, Append to first table );
//Close this temporary data table without saving
Close( dt_temp, nosave );
Wait(.001);
);