jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.59k stars 590 forks source link

fix database.export(json),yaml in chinese will get u787979 problems #475

Closed Galaxyjia closed 3 years ago

Galaxyjia commented 3 years ago

when load *.xlsx in 'rb' and have some chinese in data, it will keep unicode in data. such as '\u8979766' and when try to export in json or yaml,it will still keep the unicode in format

data = tablib.Dataset()
with open('data.xlsx','rb') as fh:
    data.load(fh,'xlsx')
print(data.dict)
print(json.dumps(data.dict,ensure_ascii=False))

with open('data.json','w') as f:
    f.write(data.export('json'))

with open('data.json','w') as f:
    f.write(json.dumps(data.dict,ensure_ascii=False))
hugovk commented 3 years ago

Please could you add tests? This will help ensure there are no future regressions.

Galaxyjia commented 3 years ago

Please could you add tests? This will help ensure there are no future regressions.

ok,I will add tests in a few days.

claudep commented 3 years ago

I completed this patch in #484.