I am getting a table view from a Stored Procedure, but for some reason the columns are out of order…
Measurement 1, Measurement 10, Measurement 11, Measurement 12… Measurement 19, Measurement 2.
Obviously I want Measurement 1, Measurement 2, measurement 3, etc. Is there a way to do this with the Table Customizer??
Here is some code I wrote to swap columns in a PyDataSet:
[code]#############################################################################################################################
sortColumnOrderListData(listdata, listcolumnsortorder)
Update the listdata columns based on the listcolumnsortorder.
Super fast way to swap columns in memory.
listdata - the PyDataSet that we will use and retuen with the columns swapped
listcolumnsortorder - the sort order, this should be a PySequence of numbers
Example:
l = [[“test”, “this”, “a”, “only”, “is”], [“fast”, “wow!”, “was”, “really”, “it”]
o = [4, 0, 3, 2, 1]
l = app.listconfig.sortColumnOrderListData(l, o)
#l = [[“this”, “is”, “only”, “a”, “test”], [“wow!”, “it”, “really”, “was”, “fast”]
def sortColumnOrderListData(listdata, listsortorder):
#AJA (2013-08-29) RM#436 add global for ordering columns
global sortColumnOrderListDataResults
sortColumnOrderListDataResults = [row for row in listdata]
sortColumnOrderListDataResults.append(listsortorder)
resultsTransposed = zip(*sortColumnOrderListDataResults)
resultsTransposed = sorted(resultsTransposed, key=lambda x: x[len(sortColumnOrderListDataResults)-1])
results = zip(*resultsTransposed)
results = results[0:-1]
resultsTmp = results
results = []
for row in resultsTmp:
resultRow = []
for val in row:
resultRow.append(val)
results.append(resultRow)
return results
[/code]
anna
3
tbackus, what is the column order returned when you run this stored procedure outside of Ignition?