Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umihico/ppickle
multilingual human-readable output pickler
https://github.com/umihico/ppickle
pickle
Last synced: about 2 months ago
JSON representation
multilingual human-readable output pickler
- Host: GitHub
- URL: https://github.com/umihico/ppickle
- Owner: umihico
- Created: 2019-01-14T10:18:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-19T01:38:52.000Z (almost 6 years ago)
- Last Synced: 2024-11-15T10:59:09.398Z (about 2 months ago)
- Topics: pickle
- Language: Python
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ppickle
multilingual human-readable output pickler## Installation
```
pip install ppickle
```## How to use
```
>>> data = {'ar': 'عربى', 'en': 'english', 'jp': '日本語', 'ko': '한국어'}
>>> import ppickle
>>> ppickle.dump('data.txt', data)
$ cat data.txt
{'ar': 'عربى', 'en': 'english', 'jp': '日本語', 'ko': '한국어'}
```
Yes, your data keep its look the same on disk regardless of language!
```
>>> loaded = ppickle.load('data.txt')
>>> loaded['jp']
日本語
>>> loaded == data
True
```## Other builtin ways
```
>>> data = {'ar': 'عربى', 'en': 'english', 'jp': '日本語', 'ko': '한국어'}
>>> import pickle
>>> with open('data.txt', 'wb') as f:
>>> pickle.dump(data, f)
$ cat data.txt
{"ar": "\u0639\u0631\u0628\u0649", "en": "english", "jp": "\u65e5\u672c\u8a9e", "ko": "\ud55c\uad6d\uc5b4"}
$ python -m pickle data.txt # you need specific command to see origin look
{'ar': 'عربى', 'en': 'english', 'jp': '日本語', 'ko': '한국어'}
``````
>>> data = [('ar', 'عربى'), ('en', 'english'), ('jp', '日本語'), ('ko', '한국어')]
>>> import json
>>> with open('data.txt', 'w', encoding='utf-8') as f:
>>> json.dump(data, f, ensure_ascii=False)
$ cat data.txt
[['ar', 'عربى'], ['en', 'english'], ['jp', '日本語'], ['ko', '한국어']]
# pretty close by using ensure_ascii=False option but inside tuples became lists
```