你好,
我想根據數據表的名稱連接數據表。
例如,我有 6 個資料表,它們的名稱類似於 M1a M1b M2a M2b M3a M3b。 所以我想將所有 M1 裝置連接在一起等。但是,M1 部分會因名稱而異,因此我需要腳本能夠取得名稱,然後比較名稱的一部分。
非常感謝任何入門幫助
桌子已經開放了嗎? 如果不是,它們是否在同一個資料夾中,並且該資料夾中是否還有其他檔案?
<< 取得名稱可用於取得資料表的名稱和取得資料表列表()開啟的資料表的清單。 要比較資料表名稱,有很多選項,使用哪個選項取決於您的資料表名稱(正規表示式是一種選項)。
這是一個腳本,可以幫助您開始將最終腳本組合在一起。它會建立一些用於範例的範例表,然後查找它們並匹配名稱中的前 2 個字符,最後將它們連接起來。
Names Default To Here( 1 );
// create sample data tables
For( i = 1, i <= 6, i++,
New Table( "M" || Char( Mod( i, 3 ) + 1 ) || Char( i ), New Column( "D" ) );
Data Table( "M" || Char( Mod( i, 3 ) + 1 ) || Char( i ) ) << add rows( 1 );
Column( Data Table( "M" || Char( Mod( i, 3 ) + 1 ) || Char( i ) ), 1 )[1] = i;
);
// Find all data tables that match Mx
concatTableList = {};
shortNameList = {};
For( i = 1, i <= N Table(), i++,
If( Starts With( Data Table( i ) << get name, "M" ),
Insert Into( concatTableList, Data Table( i ) << get name );
Insert Into( shortNameList, Substr( Data Table( i ) << get name, 1, 2 ) );
)
);
// Find the unique key values
theKeys = Associative Array( shortNameList ) << get keys;
// Create the concatenated tables
For Each( {key}, theKeys,
catList = {};
For Each( {tableName}, concatTableList,
If( Starts With( tableName, key ),
Insert Into( catList, tableName )
)
);
If( N Items( catList ) > 1,
dt = New Table( key );
For Each( {cat}, catList, dt << concatenate( Data Table( cat ), append to first table ) );
);
);您也可以考慮使用多個文件導入。 將所有表組合成單一資料表,然後使用來源列將它們分成子集(根據您想要的群組的來源列建立新列)或使用通配符 * 多次執行 MFI(符合零個或多個字元),? (精確匹配一個字元)和 ; (分隔不同的檔案名稱模式)透過一次 MFI 運作取得所有單一群組

我認為這行不通,因為它們都來自同一個 Excel 工作簿。 我打開此工作簿,每個工作表都變成一個新的資料表。 有辦法讓它發揮作用嗎?
如果只是一個 Excel 文件,您可以使用 Excel 匯入精靈。

啟用「連線工作表並嘗試比對列」和「連線時使用工作表名稱建立列」。 JMP 表中有資料後,建立分組列並根據需要建立子集。