“I would rather spend one lifetime with you, than face all the ages of this world alone.“
J.R.R. Tolkien
pip3 install beautifulsoup4 emoji
Click 「Export chat history」 on the top right corner of Telegram Desktop.
In a typical export of Telegram message folder, there will be files like this:
.
├── css
│ └── style.css
├── images
├── js
│ └── script.js
├── messages2.html
├── messages3.html
├── messages4.html
├── messages5.html
├── messages.html
└── stickers
Just put the parse.py
with those .html
s.
Run
python3 parse.py
and your chat log will be in chat_history.csv
like this:
Run tg-report.ipynb
in Jupyter Notebook, if you don't have one, you may try it out in Google Colab.
First of all, we can know how many chat items are there, maybe using WC?
➜ cat chat_history.csv | wc -l
629529
How many times we say "Good Night" to each other?
➜ cat chat_history.csv | grep "晚安" | wc -l
504213
Wow, the "Good Night rate" is about 80%.
Here are the example visualizations with generated data samples.
Of course we have this feature, but due to the possiblity of leaking sensitive data, I cannot provide a screenshot here, it's for your discovery.