Skip to content

Instantly share code, notes, and snippets.

@ompugao
Last active January 11, 2024 11:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 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')])
@FrancYescO
Copy link

change data['post']['create_at'] to data['post']['create_at']/1000 as mattermost export timestamp in millisecond otherwise slack will give (undetailed) error faling the import.

@tuler
Copy link

tuler commented May 7, 2021

Can you provide more detail on which export tool should I use to create the input file for this script?

@lpilz
Copy link

lpilz commented Nov 22, 2022

Any chance one could modify this to include threads?

@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