# Csv header encoding problem

**URL:** <https://forum.inductiveautomation.com/t/csv-header-encoding-problem/44093>\
**Category:** Ignition\
**Tags:** scripting, ignition80\
**Created:** [March 4, 2021, 12:51pm UTC](https://forum.inductiveautomation.com/t/csv-header-encoding-problem/44093 "2021-03-04T12:51:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chengdi123000](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@chengdi123000](https://forum.inductiveautomation.com/u/chengdi123000)\
**Post date:** [March 4, 2021, 12:51pm UTC](https://forum.inductiveautomation.com/t/csv-header-encoding-problem/44093/1 "2021-03-04T12:51:08Z")

</div>

OS: win10 Chinese edition, default encoding is GBK (codepage 936)  
version: 8.0.16, Maker’s edition

If there is chinese character in tag path, when I export historial dataset to csv file, the header contains unidentified characters.

```python
hist_tag_list=['a','b']

## convert tag path to name
names = [re.sub(string_before_tag_path,'',p).decode() for p in hist_tag_list]
print(names)

# default is CST UTC+8
start_datetime = system.date.parse('2020-12-18 14:30:00', 'yyyy-MM-dd HH:mm:ss')
end_datetime = system.date.parse('2020-12-18 15:45:00', 'yyyy-MM-dd HH:mm:ss')
print 'start at: ', start_datetime
print 'end at: ', end_datetime

data = system.tag.queryTagHistory(paths=hist_tag_list, columnNames=names,
startDate=start_datetime, endDate=end_datetime, returnSize=100, aggregationMode="Average", returnFormat='Wide')

# Turn that history data into a CSV.
csv = system.dataset.toCSV(dataset = data, showHeaders = True, forExport = False,localized = False)
 
# Export that CSV to a specific file path. The r forces it to use the raw path and not require double backslashes.
system.file.writeFile(r"C:\workspace\n2o\myExport.csv", csv)

```

Currently, my solution is pass `columnNames` to `system.tag.queryTagHistory()`. And the `columnNames` are passed as decoded unicode strings. Then open the generated `myExport.csv` file using `GBK` encoding.
