# Export/import a dataset to /from a sting

**URL:** <https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138>\
**Category:** Ignition\
**Created:** [June 16, 2015, 5:51pm UTC](https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138 "2015-06-16T17:51:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaopmrod2](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@joaopmrod2](https://forum.inductiveautomation.com/u/joaopmrod2)\
**Post date:** [June 16, 2015, 5:51pm UTC](https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138/1 "2015-06-16T17:51:36Z")

</div>

Is it possible to export/import a dataset to/from a string (instead a .csv file)?

I want to save the complete dataset as string in a database field.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 16, 2015, 7:42pm UTC](https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138/2 "2015-06-16T19:42:00Z")

</div>

The dataset type is serializable, so that would be a possibility: wrap a ByteArrayOutputStream in an ObjectOutputStream, use writeObject() to fill the byte array with the serialized dataset, then save the bytes to a suitable database column.  
An alternative is to use java.beans.XMLEncoder … I’ve played with this, but not enough to recommending it yet 🙂

---

<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 17, 2015, 3:09pm UTC](https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138/3 "2015-06-17T15:09:21Z")

</div>

The StringIO module should be good for this.

Easy enough to encode the dataset into a csv string. The issue may be when you pull it back out and need the original data types.

The attached window strives to overcome that.

[CSV Strings\_2017-06-27\_1053.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cb5ae63d12a972526495d595ef5e7b2b679e68ab.proj) (44.7 KB)

Hopefully, this will give you some ideas. 😉

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f4c0050c3305096d77d910806691c965d5828c0b.png)

---

<div class="post-metadata">

**Author:** ![joaopmrod2](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@joaopmrod2](https://forum.inductiveautomation.com/u/joaopmrod2)\
**Post date:** [June 18, 2015, 3:13pm UTC](https://forum.inductiveautomation.com/t/export-import-a-dataset-to-from-a-sting/10138/4 "2015-06-18T15:13:11Z")

</div>

[quote=“pturmel”]The dataset type is serializable, so that would be a possibility: wrap a ByteArrayOutputStream in an ObjectOutputStream, use writeObject() to fill the byte array with the serialized dataset, then save the bytes to a suitable database column.  
[/quote]

That worked perfectly!

[quote=“JordanCClark”]The StringIO module should be good for this.

Easy enough to encode the dataset into a csv string. The issue may be when you pull it back out and need the original data types.

Hopefully, this will give you some ideas. 😉[/quote]

I’ll also try this!

Thanks
