开发者

Output dictionary to csv file

开发者 https://www.devze.com 2023-02-13 13:10 出处:网络
I have a nested dictionary in the following format开发者_C百科, used for internationalization (this allows our translators and non-programmers to edit this file as necessary; my backup plan is to use

I have a nested dictionary in the following format开发者_C百科, used for internationalization (this allows our translators and non-programmers to edit this file as necessary; my backup plan is to use JSON format, but this would not be as suitable for these users..).

dict[LANGUAGE][KEY] = VALUE

I output this into a csv file in the following format:

KEY, VALUE-LANG-1, ... VALUE-LANG-N

where VALUE-LANG-I = dict[LANGUAGE-I][KEY]

This works fine, so long as the VALUEs are simple strings. I run into a problem, though, if the VALUE is anything more complex (a nested dict or a list). Is there a way to handle this robustly?


It is hard to suggest an alternative format suitable for manual editing by non-technical users without knowing the exact details of the data structures you want to store there (e.g. the nested dicts/lists that you mention).

One obvious suggestion is to stick with a computer-friendly format and provide a usable GUI for editing those files.

0

精彩评论

暂无评论...
验证码 换一张
取 消