The simplest way to add ENo 1, ENo 2, ENo 3 into the rows of the table is to use a ROW_NUMBER() type function. In SQL Server, it looks like:
ROW_NUMBER() OVER (ORDER BY column_name ASC) AS description
And you can use it in your query like:
SELECT 'ENo ' + ROW_NUMBER() OVER (ORDER BY itemname ASC) AS rowid, itemname, itemvalue
FROM mytable
In MySQL, you have to put this in a stored procedure and use:
set @i = 0;
select CONCAT('ENo ', @i:=@i+1) as rowid, itemname, itemvalue from mytable;
If you want to have random names in that column instead of numbers (ie: machine15, machine 22, machine 19 or east unit, west unit, south unit), you will need to do this with a python script that takes in the raw data set and creates a new one.
OK, if you want to add custom rows its starts to become more difficult. Especially if you don’t know how many rows there will be in the dataset. Here is an example that will take a list of strings and put them in the first column of the dataset. It expects
that there is a Dynamic Property called ‘rawData’ that is bound to a SQL query
that there is a property named ‘data’ that is not bound to anything
that it is being run from a propertyChange Event
if event.propertyName == "rawData":
#get the raw dataset that contains 2 columns, ItemB and ItemC
rawData = system.dataset.toPyDataSet(event.source.rawData)
#create a list of all the string values you are going to put into the first column
firstColumn = ["ENo1", "ENo2", "ENo3"]
#create the final dataset headers and an empty dataset to construct it
newHeader = ["ItemA", "ItemB", "ItemC"]
newData = []
#create a counter for the row number
i = 0
#iterate through the rows
for row in rawData:
#append a new row that includes the first column
newData.append([firstColumn[i], row[0], row[1]])
#incriment the counter for the next row if it will be a valid index
if i+1 < len(firstColumn):
i += 1
#set the new data into the final dataset
event.source.data = system.dataset.toDataSet(newHeader, newData)If the number of rows in rawData is more than the number of items in firstColumn, then the script will repeat the last item in firstColumn (instead of giving you an error).