# Special Characters in CSV

**URL:** <https://forum.inductiveautomation.com/t/special-characters-in-csv/36527>\
**Category:** Ignition\
**Created:** [July 9, 2020, 7:00am UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527 "2020-07-09T07:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amalric.sterlin](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amalric.sterlin](https://forum.inductiveautomation.com/u/amalric.sterlin)\
**Post date:** [July 9, 2020, 7:00am UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527/1 "2020-07-09T07:00:00Z")

</div>

Hello,  
I have issues with special characters in CSV.

I have got a dataset with strings containing some characters like “é” or “à”, encoded like this :

string = u"This is the string with é and à" (as an example)

I export the dataset as a .csv file.

When I want to upload back this file, the encoding of the characters is not recognized and I have question marks standing for them.

Is there a way to pass the utf8 encoding through the .csv to keep the special characters ?

Thank you for your help,

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 9, 2020, 4:17pm UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527/2 "2020-07-09T16:17:20Z")

</div>

Can you post your full script? Using `system.dataset.toCSV/fromCSV`, I get the same characters out and back in:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c82b4f2d8b65e6b2c5e6df2cef2fc81efc9d637.png)

```python
from com.inductiveautomation.ignition.common.util import DatasetBuilder
from java.lang import String, Integer, Double, Boolean
from java.util import Date

ds = (DatasetBuilder
	.newBuilder()
	.colTypes(Integer, String, Double, Boolean, Date)
	.colNames("Int", "String", "Double", "Boolean", "Date")
	.addRow(123, u"This is the string with é and à", 123, True, system.date.now())
	.addRow(None, None, None, None, None)
	.addRow(123, "Abc", 123, True, system.date.now())
	.build())

t = system.dataset.toCSV(ds, True, True, False)
p = system.file.saveFile("test.csv")
print p
system.file.writeFile(p, t)

read = system.file.readFileAsString(p)
readDs = system.dataset.fromCSV(read)
pyds = system.dataset.toPyDataSet(readDs)

for col in pyds:
	for row in col:
		print row

```

What _might_ be the issue is the encoding when reading the file back in - you can force an encoding argument (I’d recommend `UTF-8`, for sanity) to [`system.file.writeFile`](https://docs.inductiveautomation.com/display/DOC80/system.file.writeFile) / `readFileAsString` to ensure things are decoded correctly.

---

<div class="post-metadata">

**Author:** ![amalric.sterlin](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amalric.sterlin](https://forum.inductiveautomation.com/u/amalric.sterlin)\
**Post date:** [July 10, 2020, 7:53am UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527/3 "2020-07-10T07:53:01Z")

</div>

Thank you for your answer.

Here is my dataset in a table :

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

I an downloading it with this script :

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c68d83aed421421391e6129716f757375e7957c6.png)

And uploading the data with this :

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

And i get this back :

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 10, 2020, 3:58pm UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527/4 "2020-07-10T15:58:25Z")

</div>

Try adding the encoding argument to `system.file.writeFile`. If you open the file in a text editor separately, does it have encoding errors or have the properly encoded values?

---

<div class="post-metadata">

**Author:** ![amalric.sterlin](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amalric.sterlin](https://forum.inductiveautomation.com/u/amalric.sterlin)\
**Post date:** [July 13, 2020, 8:09am UTC](https://forum.inductiveautomation.com/t/special-characters-in-csv/36527/5 "2020-07-13T08:09:51Z")

</div>

Ok I have added the encoding in writeFile() and it is working ! Thank you !
