Skip to content

Update README and Makefile #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
go.work
go.work.sum

# Command directories
SlackMessages
slack_records.csv

# IDE directories and misc. files
.idea
.vscode
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ lint:
go fmt ./...
go vet ./...
staticcheck ./...

.PHONY: parse-slack-data
parse-slack-data:
go run ./cmd/slackMessageParser/main.go
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ Various scripts written in Golang.
## Scripts

### Slack Message Parser
This tool is used to parse the `json`-formatted data that comes from [exporting Slack workspace data](https://slack.com/help/articles/201658943-Export-your-workspace-data) into a `csv` file named: `slack_records.csv`.

`csv` format:
TimeStamp,UserID,UserName,RealName,MessageType,Text,Attachments,Files

| TimeStamp | UserID | UserName | RealName | MessageType | Text | Attachments | Files |
|:---------:|:------:|:--------:|:--------:|:-----------:|:------:|:-----------:|:--------:|
| string | string | string | string | string | string | []string | []string |

#### Instructions
```console
cp [YOUR_ARCHIVE_PATH_HERE]/*.json ./SlackMessages/
go run slack_message_parser.go
```
1. Move your files to the `SlackMessages` directory.
```console
mkdir -p ./SlackMessages
cp [SLACK_WORKSPACE_DATA_PATH_HERE]/*.json ./SlackMessages/
```
2. Run the Slack message parser using the command: `make parse-slack-data`.
6 changes: 3 additions & 3 deletions cmd/slackMessageParser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ type CSVRecord struct {
}

func main() {
if _, err := os.Stat("../../SlackMessages"); os.IsNotExist(err) {
if _, err := os.Stat("./SlackMessages"); os.IsNotExist(err) {
log.Fatal("the ./SlackMessages directory does not exist")
}

files, err := filepath.Glob("../../SlackMessages/*.json")
files, err := filepath.Glob("./SlackMessages/*.json")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -156,7 +156,7 @@ func main() {
csvRecords = append(csvRecords, record)
}

csvFile, err := os.Create("../../slack_records.csv")
csvFile, err := os.Create("slack_records.csv")
if err != nil {
log.Fatal(err)
}
Expand Down
Loading