Skip to content

Commit cbcaa04

Browse files
authored
Update README and Makefile (#2)
## Describe your changes Added missing information to README and a missing command to the `Makefile`. ## Checklist before requesting a review - [x] The code runs successfully. ```console michaelp@MacBook-Air-18 golang-scripting % ls LICENSE Makefile README.md cmd go.mod go.sum michaelp@MacBook-Air-18 golang-scripting % make parse-slack-data go run ./cmd/slackMessageParser/main.go 2024/07/16 00:08:50 the ./SlackMessages directory does not exist exit status 1 make: *** [parse-slack-data] Error 1 michaelp@MacBook-Air-18 golang-scripting % mkdir -p ./SlackMessages michaelp@MacBook-Air-18 golang-scripting % make parse-slack-data go run ./cmd/slackMessageParser/main.go 2024/07/16 00:11:16 could not find *.json files in the ./SlackMessages directory exit status 1 michaelp@MacBook-Air-18 golang-scripting % cp ~/Downloads/Archive/* ./SlackMessages michaelp@MacBook-Air-18 golang-scripting % make parse-slack-data go run ./cmd/slackMessageParser/main.go michaelp@MacBook-Air-18 golang-scripting % ls LICENSE Makefile README.md SlackMessages cmd go.mod go.sum slack_records.csv michaelp@MacBook-Air-18 golang-scripting % ```
1 parent 84145cb commit cbcaa04

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
go.work
2222
go.work.sum
2323

24+
# Command directories
25+
SlackMessages
26+
slack_records.csv
27+
2428
# IDE directories and misc. files
2529
.idea
2630
.vscode

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ lint:
1010
go fmt ./...
1111
go vet ./...
1212
staticcheck ./...
13+
14+
.PHONY: parse-slack-data
15+
parse-slack-data:
16+
go run ./cmd/slackMessageParser/main.go

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ Various scripts written in Golang.
44
## Scripts
55

66
### Slack Message Parser
7+
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`.
78

9+
`csv` format:
10+
TimeStamp,UserID,UserName,RealName,MessageType,Text,Attachments,Files
11+
12+
| TimeStamp | UserID | UserName | RealName | MessageType | Text | Attachments | Files |
13+
|:---------:|:------:|:--------:|:--------:|:-----------:|:------:|:-----------:|:--------:|
14+
| string | string | string | string | string | string | []string | []string |
815

916
#### Instructions
10-
```console
11-
cp [YOUR_ARCHIVE_PATH_HERE]/*.json ./SlackMessages/
12-
go run slack_message_parser.go
13-
```
17+
1. Move your files to the `SlackMessages` directory.
18+
```console
19+
mkdir -p ./SlackMessages
20+
cp [SLACK_WORKSPACE_DATA_PATH_HERE]/*.json ./SlackMessages/
21+
```
22+
2. Run the Slack message parser using the command: `make parse-slack-data`.

cmd/slackMessageParser/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ type CSVRecord struct {
7474
}
7575

7676
func main() {
77-
if _, err := os.Stat("../../SlackMessages"); os.IsNotExist(err) {
77+
if _, err := os.Stat("./SlackMessages"); os.IsNotExist(err) {
7878
log.Fatal("the ./SlackMessages directory does not exist")
7979
}
8080

81-
files, err := filepath.Glob("../../SlackMessages/*.json")
81+
files, err := filepath.Glob("./SlackMessages/*.json")
8282
if err != nil {
8383
log.Fatal(err)
8484
}
@@ -156,7 +156,7 @@ func main() {
156156
csvRecords = append(csvRecords, record)
157157
}
158158

159-
csvFile, err := os.Create("../../slack_records.csv")
159+
csvFile, err := os.Create("slack_records.csv")
160160
if err != nil {
161161
log.Fatal(err)
162162
}

0 commit comments

Comments
 (0)