# Tag History to CSV and Back how do i fix ignition crash?

**URL:** <https://forum.inductiveautomation.com/t/tag-history-to-csv-and-back-how-do-i-fix-ignition-crash/75124>\
**Category:** Ignition\
**Created:** [June 16, 2023, 7:54am UTC](https://forum.inductiveautomation.com/t/tag-history-to-csv-and-back-how-do-i-fix-ignition-crash/75124 "2023-06-16T07:54:48Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 16, 2023, 11:30am UTC](https://forum.inductiveautomation.com/t/tag-history-to-csv-and-back-how-do-i-fix-ignition-crash/75124/8 "2023-06-16T11:30:12Z")

</div>

Inserting a row at a time is going to be less efficient. A series of ops should be something like:

```python
csvRead = csv.reader(csvFile),
csvDataset = []
count = 0
for row in csvRead:
    csvDataset.append(row)
    count += 1
    if count >= 1000:
    	insert_into_DB_here()
    	csvDataset = []
    	count = 0
if count>0:
	last_insert_into_db()

csvFile.close()

```

If you use system.db.runPrepUpdate to insert your rows, I do have a helper function to create the question marks for you.

> [@Pass parameter to tag.writeAsync](https://forum.inductiveautomation.com/t/pass-parameter-to-tag-writeasync/43485/13):
>
> Sorry, I was pulled into a meeting as I was typing this, but if it helps, I do have a function to generate question marks for prep inserts. def prepInsertQmarks(numOfGroups, groupSize): ''' Generate a string of grouped question marks for prepUpdate inserts example: Generate three groups of four question marks: prepInsertQmarks(3, 4) returns (?,?,?,?),(?,?,?,?),(?,?,?,?) ''' group = '(' + ','.join(['?'] \* groupSize) + ')' return ','.join([group] \* numOfGroups) query = """ …

---

_[View the full topic](https://forum.inductiveautomation.com/t/tag-history-to-csv-and-back-how-do-i-fix-ignition-crash/75124)._
