Convert exported Whatsapp chat text files to JSON message file containing messages. Also convert JSON message file to JSON word 'frequency of use' file.
Go to the chat you want to export, then go to Group Info, select Export Chat (Without Media), export and unzip it to extract the txt file.
How to convert the chat txt file to a JSON file containing an array of all messages with timestamp and user information. By default 'omitted media' lines and message type information is excluded.
npm run messages -- _your_chat_file.txt
Appending -t flag will add message type property in generated JSON file.
npm run messages -- _your_chat_file.txt -t
Appending -m flag will retain 'omitted media' lines
npm run messages -- _your_chat_file.txt -m
How to convert the JSON message file into a JSON file of all words and their frequency of use.
npm run words -- _your_chat_file-messages.json
Appending -a flag will not include any words with apostrophes in them.
npm run words -- _your_chat_file-messages.json -a
{
"data":[
{"date":"2014-02-11T14:41:17.000Z","user":"Dave","message":"Dave changed the subject to “Test Chat”","type":"action"},
{"date":"2014-02-11T14:41:24.000Z","user":"Dave","message":"Dave was added","type":"action"},
{"date":"2014-02-11T14:41:24.000Z","user":"You","message":"You were added","type":"action"},
{"date":"2014-02-11T14:41:25.000Z","user":"John","message":"John was added","type":"action"},
{"date":"2014-02-11T14:41:38.000Z","user":"Dave","message":"Testing testing, this is a test message","type":"message"},
{"date":"2014-02-11T14:42:32.000Z","user":"Rich","message":"Testing again.","type":"message"},
{"date":"2014-02-11T14:42:43.000Z","user":"John","message":"Still testing...?","type":"message"}
]
}
{
"data":{
"guys":297,
"down":343,
"trumpets":10,
"weekend":218,
"mate":171
}
}
npm run messages -- ./example/_example_chat.txt -t -m
// written to ./example/_example_chat-messages.json...
npm run words -- ./example/_example_chat-messages.json -a
// formatting messages...
// collating and filtering words...
// creating unique words object...
// written to ./example/_example_chat-words.json