Error Font (Vietnamese) When import to power table in ignition

I have an Excel file, I save as it to csv file ( CSV UTF-8).
When i import to power table using code below:
" import csv
path = system.file.openFile("csv")
csvData = csv.reader(open(path))
header = csvData.next()
dataset = system.dataset.toDataSet(header ,list(csvData))
event.source.parent.getComponent('Power Table').data = dataset
"
I have an error with font (vietnamese) like the pictures
Can anyone have a solution for this ?
thanks a lot

Can you share both the CSV and Excel files? Looks loke a unicode issue, but it would be easier to help troubleshoot with the files. :slight_smile:

Because jython is python 2 and therefore its modules have horrible unicode support. It's a bit more trouble but I would use a java FileInputStream and java's parsing tools. Something like the techniques here:

For challenging cases, I use java.io.StreamTokenizer. It can properly handle commas within quoted values.

3 Likes

Product Plan.csv (3.1 KB)
Production Plan .xlsx (15.4 KB)
This's 2 file .xlsx and .csv

Thanks for your advice
I will try this one

Your spreadsheet doesn't really lend itself well to creating a dataset with the way the headers are arranged. Merged cells don't exist in datasets, either.
I recommend moving / removing items that are not related to the dataset.

Production Plan-revised headers.xlsx (15.2 KB)

I was then able to import directly from the excel file. using the function provided here:

path = system.file.openFile('xlsx')
dataset = util.excelToDataSet(path, hasHeaders = True, firstRow = 2, firstCol = 1, lastCol = 9)
event.source.parent.getComponent('Power Table').data = dataset

thanks a lots, I will try this one again
thanks for your Supporting