# toCSV vs exportCSV

**URL:** <https://forum.inductiveautomation.com/t/tocsv-vs-exportcsv/26537>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [July 13, 2019, 10:24am UTC](https://forum.inductiveautomation.com/t/tocsv-vs-exportcsv/26537 "2019-07-13T10:24:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [July 13, 2019, 10:24am UTC](https://forum.inductiveautomation.com/t/tocsv-vs-exportcsv/26537/1 "2019-07-13T10:24:06Z")

</div>

When I use system.dataset.toCSV to export Russian translations from table

 ![translationTable](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/01aad9ed4bfeee43b91e94a396ff16341e7b5c7c.png)  
to .csv, I get this:  
 ![toCSV](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cec965d1d70b6e6b0aa1f56ad47afd8ed91cdad6.png)  
When I use system.dataset.exportCSV, I get this:  
 ![exportCSV](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/01345f4edb72521247b7f156a4240eb3270d6e8d.png)  
To import csv there’s only one function: system.dataset.fromCSV, which requires csv format from .toCSV.  
But that file doesn’t have Russian text, but only ???..  
So, how can I export and import Russian texts?

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [July 13, 2019, 11:31am UTC](https://forum.inductiveautomation.com/t/tocsv-vs-exportcsv/26537/2 "2019-07-13T11:31:47Z")

</div>

I found the solution here:  
[https://stackoverflow.com/questions/904041/reading-a-utf8-csv-file-with-python](https://stackoverflow.com/questions/904041/reading-a-utf8-csv-file-with-python)

And this my working script (on buttons actionPerformed):

```auto
import csv

def unicode_csv_reader(utf8_data, dialect=csv.excel, **kwargs):
    csv_reader = csv.reader(utf8_data, dialect=dialect, **kwargs)
    for row in csv_reader:
        yield [unicode(cell, 'utf-8') for cell in row]

parent = event.source.parent

locale = parent.getComponent('Dropdown').selectedStringValue

file = system.file.openFile("csv")
if file != None:
	csvData = unicode_csv_reader(open(file))
	header = csvData.next()
	
	dataset = system.dataset.toDataSet(header ,list(csvData))
	dsLocale = system.dataset.getColumnHeaders(dataset)[1]
	if dsLocale != locale:
		system.gui.messageBox("locale of CSV (%s) doesn't match selected locale (%s). Aborting." % (dsLocale, locale))
	else:
		oldData = parent.getComponent('Table').data
		parent.getComponent('Table').data = dataset
		if system.gui.confirm("Is data correct for locale %s?\nThis will override any existing translations" % locale):
			
			pyDs = system.dataset.toPyDataSet(dataset)
			for row in pyDs:
				term = row[0]
				newValue = row[1] or None
				#print "term, newValue= ", term,newValue
				system.util.modifyTranslation(term, newValue, locale)
		else:
			parent.getComponent('Table').data = oldData

```

If you have a lot of lines in your .csv file (mine have more than 5200) it’ll take a while and block Ignition thread.  
So, system.util.invokeAsynchronous with system.util.invokeLater must be used not to block the Vision thread and show the user some progress feedback…
