# Issue with Dataset export to CSV, including float

**URL:** <https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 21, 2024, 8:56pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708 "2024-05-21T20:56:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [May 21, 2024, 8:56pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/1 "2024-05-21T20:56:02Z")

</div>

Hi,

I'm in trouble in exporting (trough system.dataset.toCSV and forExport=True) a simple Power table dataset [2R x 3C] , if it is including a "float". The export seems corrupted, having "#ROWS","3" (instead of 2, as I see in property) and no "#Types" (hereby included the CSV). The data  
[test2.csv](https://forum.inductiveautomation.com/uploads/short-url/tJeLkQJNZvnNS9r4lX2PaHI4kMk.csv) (93 Bytes)  
are aggregated by Col (!) and not by Row, as should be. If I remove the 3rd column (the Float) the CSV is OK. Anyone can help about? Thanks.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [May 21, 2024, 8:59pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/2 "2024-05-21T20:59:14Z")

</div>

You'll probably need to share the code as well as the source data object

---

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [May 21, 2024, 9:18pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/4 "2024-05-21T21:18:41Z")

</div>

The source here:

 ![Screenshot 2024-05-21 alle 23.16.29](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d8d7188b42c9451a495d2e5284b4f0466daf0e39.png)

The referenced Power Table has a simple dataset with 3Columns: 1 Str, 1 Int, 1 Float,  
The ouput (CSV) is in the previous post.

If I remove the 3rd column (the float) all is working

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [May 21, 2024, 9:44pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/5 "2024-05-21T21:44:26Z")

</div>

Have you tried using [system.dataset.exportCSV](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-dataset/system-dataset-exportCSV) instead? The forExport flag seems to be in order to make a string that matches the system.dataset.fromCSV, rather than a "raw" CSV string.

---

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [May 21, 2024, 10:02pm UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/6 "2024-05-21T22:02:21Z")

</div>

system.dataset.exportCSV does not export the #TYPES and others. As per the manual.  
The system.dataset.toCSV exports the the format that is fully compatible with import, as I need, and as per the manual. If it works with str, int, etc. the same should be with float without "tranposing" Rows and Cols

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [May 22, 2024, 12:34am UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/7 "2024-05-22T00:34:30Z")

</div>

I'm very confused, your file test2.csv

```python
"#NAMES"
"Descr","INT1","FL1"
"#TYPES"
"str","I","F"
"#ROWS","2"
"A","1","1.1"
"B","2","2.2"

```

Does show "#ROWS", "2". Is there another corrupted file?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 22, 2024, 4:22am UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/8 "2024-05-22T04:22:01Z")

</div>

This is the cause of the problem:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/b/ab467a180b5a9f8d31024bbde7dfe6236e81dc17.png)

See the `.data` on the end of that? The data property of the power table is being retrieved instead of the power table component itself.

Then, in the next line, an attempt is made to get the data property from the resultant dataset because the assumption is that this is actually the power table itself:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/3/d31b215c1cc37dcb0e3f3fc75a7d91462893e483.png)

Either remove the `.data` from the component variable assignment, or simply retrieve the dataset instead, and use it in the `toCSV` call.

**Example:**

```python
# Get the dataset from the power table's data property
dataset = event.source.parent.getComponent('Power Table').data

# Convert the dataset to a csv file
csv = system.dataset.toCSV(dataset, forExport = True)

# Have the user pick a file path
filePath = system.file.saveFile('myExport.csv', 'csv', 'Comma Setperated Values')

# If a filepath has been returned, write the csv accordingly
if filePath:
	system.file.writeFile(filePath, csv)

```

---

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [May 22, 2024, 8:00am UTC](https://forum.inductiveautomation.com/t/issue-with-dataset-export-to-csv-including-float/90708/9 "2024-05-22T08:00:47Z")

</div>

Thanks Justine, you're perfecly right. My fault. The float is not involved at all.

Many thanks!!
