/slackJsonToCsv

Convert to csv from exported json data in slack service.

Primary LanguagePythonApache License 2.0Apache-2.0

json_to_csv_for_slack

Convert to csv from exported json data in slack service.

Qiitaにフォーク元の制作者の記事があります。

Environment

  • OS: Windows 11 23H2
  • python: 3.11.1
  • pyinstaller: 6.5.0

Export json file or SQL

check for official site.

How to use

# argv 1 : zip file path or unzipped folder path
# argv 2 : timestamp format
#          'kintone' or 'iso8601' -> YYYY-MM-DDTHH:MM:SS+09:00
#          other or NULL          -> YYYY-MM-DD HH:MM:SS
# argv 3 : output mode
#          'csv'         -> *.csv output
#          'mysql'       -> slack_log_mysql.sql (MySQL format) output
#                           (timestamp format [YYYY-MM-DD HH:MM:SS] only)
#          'sqlite'      -> slack_log_sqlite.sql (SQLite format) and SlackLog.db output
#                           (timestamp format [YYYY-MM-DD HH:MM:SS] only)
#          other or NULL ->  *.csv output
# argv 4 : SQL mode
#          'create'             -> create database and first insert
#          'upsert' or 'update' -> update or insert to database (MySQL ONLY)
#          other or NULL        -> create database and first insert
# argv 5 : unzip mode
#          '1' or 'true' or 'nozip' or 'notzip' or 'not_zip' -> argv 1 is unzipped folder path
#          other or NULL                                     -> argv 1 is zip file


# ex.)

$ python converter.py slack_log.zip kintone

# slack_csv_output/ALL_CHANNEL_TALK_DATA.csv
# slack_csv_output/[channel name].csv etc... 
# csv timestamp format is [YYYY-MM-DDTHH:MM:SS+09:00]


$ python converter.py slack_log.zip other sqlite

# slack_csv_output/slack_log_sqlite.sql
# slack_csv_output/SlackLog.db
# csv timestamp format is [YYYY-MM-DD HH:MM:SS]


$ python converter.py slack_log.zip other mysql upsert

# slack_csv_output/slack_log_sqlite.sql
# csv timestamp format is [YYYY-MM-DD HH:MM:SS]


$ python converter.py "Slack official export unzipped" other mysql create notzip

# slack_csv_output/slack_log_mysql.sql
# csv timestamp format is [YYYY-MM-DD HH:MM:SS]