# Dataset Confusion - inserting extra rows

**URL:** <https://forum.inductiveautomation.com/t/dataset-confusion-inserting-extra-rows/8212>\
**Category:** Ignition\
**Created:** [March 25, 2014, 4:44pm UTC](https://forum.inductiveautomation.com/t/dataset-confusion-inserting-extra-rows/8212 "2014-03-25T16:44:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![george](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/george/32/14066_2.png) [@george](https://forum.inductiveautomation.com/u/george)\
**Post date:** [March 25, 2014, 4:44pm UTC](https://forum.inductiveautomation.com/t/dataset-confusion-inserting-extra-rows/8212/1 "2014-03-25T16:44:11Z")

</div>

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”.

[code] loadRef=""  
newRows=[]  
# Loop through data  
for row in data2:  
if loadRef!=row[“Load Reference”]:  
# Avoid gap line at the start  
if loadRef!="":  
# Insert gap line  
newRows.append(["","","","","",""])  
# Store new load reference  
loadRef=row[“Load Reference”]  
# Store original data  
newRows.append([row[0], row[1], row[2], str(row[3]), row[4], str(row[5])])

```
	# Now convert to dataset
	newData2 = system.dataset.toDataSet(["Supplier","Product","Load Reference","Machine","Description","Value"], newRows)

```

[/code]

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.

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [April 15, 2014, 8:22pm UTC](https://forum.inductiveautomation.com/t/dataset-confusion-inserting-extra-rows/8212/2 "2014-04-15T20:22:51Z")

</div>

There is nothing wrong with the way you are doing this. In fact in situations where you need to append a handful or more of new rows then this method is actually preferred. Ignition datasets are immutable so they cannot be modified after they have been created. Whenever you call a function that modifies a dataset what is actually happening behind the scenes is a new dataset is being created with all the data from the old dataset plus the changes you're making. This process is rather inefficient when you have a lot of edits to make to a dataset.
