Skip to content

Instantly share code, notes, and snippets.

@ompugao
Last active April 22, 2024 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ompugao/94c7d2109b09436c9c5b70429b9eb38c to your computer and use it in GitHub Desktop.
Save ompugao/94c7d2109b09436c9c5b70429b9eb38c to your computer and use it in GitHub Desktop.
message migration from mattermost to slack
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import pprint
import csv
if __name__ == '__main__':
with open('./bulk.csv', 'w') as csvf:
writer = csv.writer(csvf, lineterminator='\n', quoting=csv.QUOTE_ALL)
with open('./bulk.json', 'r') as f:
i = 0
while True:
line = f.readline()
if not line:
break
i+=1
data = json.loads(line)
if data.has_key('post') and data['post'].has_key('channel'):# and data['post']['channel'] == 'off-topic':
#from IPython.terminal import embed; ipshell=embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())
writer.writerow([data['post']['create_at']/1000, data['post']['channel'], data['post']['user'], data['post']['message'].encode('utf-8')])
@ompugao
Copy link
Author

ompugao commented Dec 1, 2022

i dont use mattermost now. fork is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment