如何按表名對打開表進行排序<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />我一次打開多個表。打開後,我遍歷從1到N Table()的所有打開的表,並將對每個表的引用存儲在列表中。然而,當我遍歷每個打開的表時,我不確定它是如何安排在內存中的。最重要的是,我希望列表中的條目根據表名進行排序。有沒有辦法讓我在將它們存儲到列表之前對它們進行排序?或者把它放在一個不同的角度,什麼是對列表中的表引用進行排序的最佳方法(如果假設它們以隨機順序存儲在我的列表中)?
Re:如何按表名對打開表進行排序打開桌子後不要對桌子進行排序!
在打開表名之前對錶名進行排序。您可以將表名作為列表,然後在那裡使用它們。列表排序後,按順序打開它們並處理它們。
在這個腳本中: https://community.jmp.com/t5/JMP-Scripts/Combine-multiple-txt-or-csv-files/ta-p/24083
我得到一個目錄中所有文件類型的列表,然後順序打開文件。 當單個文件很大或者有數千個文件時,這很有用。
Re:如何按表名對打開表進行排序您可以使用列的值排序屬性來執行此操作。 這是一個例子:
sort_order_list = {"XXX", "AAA", "DDD", "GGG", "YYY", "QQQ"};
dt = New Table( "Untitled 15", Add Rows( 6 ),
New Column( "To Be Sorted", Character, "Nominal",
Set Values( {"AAA", "DDD", "GGG", "QQQ", "XXX", "YYY"} )
)
);
column(dt, "To Be Sorted") << set property("Value Ordering", sort_order_list);
現在,當您對列進行排序時待分類它將按列表中項目的順序排序。
Re:如何按表名對打開表進行排序不幸的是,我不確定我明白你在問什麼。
假設我有lst個字符串值,myList = {“alpha”,“gamma”,“beta”}和一個表“My Table”,其中一個名為“Vals”的列在每個單元格中都有這三個值中的一個。
你想要排序'我的表'所以所有帶有“alpha”的行首先出現,所有帶有“beta”的行都排在最後,所有帶有“gamma”的行都介於兩者之間?
Re:如何按表名對打開表進行排序如何按列表中的值而不是升序或降序對錶進行排序?
假設我在列表中有唯一的列值。並且列表中值的順序不是升序也不是降序。 我如何使用此列表對錶格進行排序?
提前致謝。
內存
Re:如何按表名對打開表進行排序謝謝。我以前應該想到這個。我之前嘗試過對列表進行排序,但只包含表名。
Re:如何按表名對打開表進行排序如果需要數據表引用列表而不是字符串,這是另一種選擇:
openTables = {};
For(i = 1, i <= N Table(), i++,
Insert Into(openTables, Data Table(i))
);
Sort List Into(openTables);
// Refer directly to table, e.g.
openTables[1] << Bring Window to Front;
Re:如何按表名對打開表進行排序對不起,我忽略了相當漂亮的'Sort List Into()''。顯然,我需要重新使用“幫助>腳本編制索引”。
所以,是的,你可以這樣做:
// Build the sorted list
openTables = {};
for(t=1, t<=NTable(), t++, InsertInto(openTables, DataTable(t) << getName));
SortListInto(openTables);
// Manipulate (Close) each table in this list
for(t=1, t<=NItems(openTables), t++, Close(DataTable(openTables[t]), NoSave); Wait(1));
Re:如何按表名對打開表進行排序@Ian,在表名被排序並存儲在openTables列表中之後,我該如何引用該表?例如,是否可以這樣做:
對於(a = 1,a <= N Table(),a ++,
tmpDT =數據表(openTables );
// ....
);
另外,這會對列表內容進行排序嗎?
將列表排序為(openTables);
問候,
克里斯
csoon1 wrote:I am opening multiple tables at once. Once opened, I loop through all open tables from 1 to N Table() and store the references to each table on a list. However as I loop through each open table, I am not sure how it is arranged in the memory. Bottom line, I want the entries on my list to be sorted according to the table name. Is there a way for me to sort the open tables before storing them to a list? Or to put it in a different angle, what's the best way to sort the table references inside my list (if assuming they are stored on my list at a random order)?
Re:如何按表名對打開表進行排序這是一種方式:
openTables = {};
for(t=1, t<=NTable(), t++, InsertInto(openTables, DataTable(t) << getName));
dt = NewTable("Invisible", NewColumn("Table Name", Character, Values(openTables)), Invisible);
dt << Sort(By("Table Name"), Ascending, ReplaceTable);
openTables = Column(dt, "Table Name") << getValues;
Close(dt, NoSave);