JMP 16:用於開啟資料夾中最新的 .csv 檔案的腳本。我一直在使用 path = Pick File();命令手動選擇要匯入資料表的檔案。 您可以編寫一個命令來將資料夾中最新的 .csv 檔案匯入到資料表中嗎? 這些文件中只有一張工作表。
資料存取回覆:JMP 16:用於開啟資料夾中最新 .csv 檔案的腳本。我過去正好有這個需求,幸運的是保存了一個腳本以防萬一...
您需要更改第 2 行和第 3 行的字串。
Names Default To Here( 1 );
searchext = "jmp"; //extension to look for
searchfolder = "$DESKTOP"; //place to search
lstExtensions = {};
lstDates = {};
lstFiles = Files In Directory( searchfolder );
For Each( {i, j}, lstFiles,
lstExtensions[j] = Char( Right( i, 3 ) );
lstDates[j] = As Date( Creation Date( searchfolder || "/" || Char( i ) ) );
);
dt = New Table( "Files",
New Column( "Name", character, set values( lstFiles ) ),
New Column( "ext", character, set values( lstExtensions ) ),
New Column( "Date", numeric, set values( Matrix( lstDates ) ) )
);
dt << Select where( :ext != searchext );
dt << Delete Rows;
newest = Col Min( :Date );
newfile = searchfolder || "/" || :Name[dt << Get Rows Where( :Date == newest )][1];
Close( dt, no save );
Open( newfile );回覆:JMP 16:用於開啟資料夾中最新 .csv 檔案的腳本。如果您想忽略時間戳,可以將檔案名稱與 Contains() 函數配對。
回覆:JMP 16:用於開啟資料夾中最新 .csv 檔案的腳本。馬克:謝謝您的回覆。 我不知道幫助下的腳本索引,所以這對未來有很大幫助。 我引用的是 JMP15 腳本指南的 pdf 版本,該指南不適合搜尋。 我對檔案名稱的一個問題是它在名稱末尾包含時間戳,因此它是動態的。 格式為 FileName_YYYYMMDDHHMM.csv。 我現在將堅持使用 PickFile 並嘗試使用 LastModificationDate 函數。 再次感謝。
回覆:JMP 16:用於開啟資料夾中最新 .csv 檔案的腳本。您是否在“幫助”>“腳本索引”中搜尋了“函數”並檢查了“檔案”函數組?

您可以將腳本基於 Creation Date() 或 Last Modification Date() 函數。