Skip to content
Advertisement

Manipulating files using Python

My old friend and I have been trying to save our chat histories recently for the nostalgia and the memories. Google chat history saves in a latest-oldest order. I’d like to make it to oldest-latest as well as change the pattern of the text. Any idea how I can implement this in Python?
For reference this is the Hangouts file.

JavaScript

And this is what I want it to look like.

JavaScript

Advertisement

Answer

You can use modules re and datetime.

Example for your text:

JavaScript

The result:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement