I’m using runPrepQuery to return a dataset which I’m then sending to Excel.
I’ve been asked to insert some blank rows in to try and make it more readable, specifically when a value in a certain column changes.
Here is part of my code. data2 holds the dataset returned from the query and the column I’m looking for a change in is “Load Reference”.
# Loop through data
for row in data2:
if loadRef!=row[“Load Reference”]:
# Avoid gap line at the start
# Insert gap line
# Store new load reference
# Store original data
newRows.append([row, row, row, str(row), row, str(row)])
# Now convert to dataset newData2 = system.dataset.toDataSet(["Supplier","Product","Load Reference","Machine","Description","Value"], newRows)
Now after much messing about this basically does seem to do what I want.
But is this the best way do to it? Is there an easier way?
Specifically, should I be able to do newRows.append(row) rather than they way I’ve done it, listing out every single column?
And also is there a way to easily reuse the column headers from the original dataset rather than defining them again like I have done? I tried the system.dataset.getColumnHeaders function but couldn’t get it to work.