# \[SOLVED\] Is there a way to convert a dataset column type?

**URL:** <https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971>\
**Category:** Ignition\
**Tags:** ignition80, vision, scripting\
**Created:** [August 16, 2021, 4:55pm UTC](https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971 "2021-08-16T16:55:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 16, 2021, 4:55pm UTC](https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971/1 "2021-08-16T16:55:21Z")

</div>

Is there a way to convert a dataset column type?

![csv_data](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a58b42bdd8d16d9f9b0dfa756255a70242ed83be.jpeg)

 ![output](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/7/c76089ba621699a85ba2cd04afc62e9c08840423.jpeg)  
 ![script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/71cb00dd845e614b40e0950ab817cc27379a5ef6.jpeg)

I am trying to import a CSV file into a dataset tag but the numbers come in as strings. What would be the easiest way to accomplish this? Thanks for any guidance.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [August 16, 2021, 6:01pm UTC](https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971/2 "2021-08-16T18:01:36Z")

</div>

Used DataSetBuilder to create a dataset with the right column types.

> [@Vision: Convert dataset column type](https://forum.inductiveautomation.com/t/vision-convert-dataset-column-type/26341/2):
>
> Use Ignition’s [DatasetBuilder](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/ignition/common/util/DatasetBuilder.html). Something like this: from com.inductiveautomation.ignition.common.util import DatasetBuilder from java.lang import Integer, String, Object from java.awt import Color def forceTypes(sqlDS): builder = DatasetBuilder.newBuilder() builder.colNames(sqlDS.columnNames) originalTypes = list(sqlDS.columnTypes) i = #some column index for a color originalTypes[i] = Color builder.colTypes(originalTypes) for r in range(sqlDS.rowCount): bui…

Then copy the rows from your dataset with the wrong types into the dataset with the correct column types.

Or it might be as easy to manipulate the CSV to specify the correct types before turning it into a dataset:

> [@Convert columntype in table to integer](https://forum.inductiveautomation.com/t/convert-columntype-in-table-to-integer/9103/5):
>
> Use system.dataset.fromCSV to specify data types and column headers for your blank dataset like this: blankDataset = """#NAMES Header1, Header2, #TYPES d,I #ROWS,0""" See [Ignition Manual](https://docs.inductiveautomation.com:8443/display/DOC79/system.dataset.fromCSV) for data types, etc.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 16, 2021, 6:18pm UTC](https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971/3 "2021-08-16T18:18:36Z")

</div>

@pturmel @witman

The man, the myth, the legend strikes again! Thanks Phil and witman.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/273a9f2e152b3ab8b0312f4920f8b1b331291207.png)

 ![import_CSV](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c63ac78480d4ce4e1eb918fffbd399887c87ee16.jpeg)

Updated code attached.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 16, 2021, 6:35pm UTC](https://forum.inductiveautomation.com/t/solved-is-there-a-way-to-convert-a-dataset-column-type/49971/4 "2021-08-16T18:35:35Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/af7244af447e2a09fff917f21113afab23f08408.png)

Updated the function to take a dictionary of integer keys and datatype values in other words

```auto
ds_dict = {0: Integer, 2: Integer}
```
