Skip to content

Commit

Permalink
sort: do not panic for empty input. #287
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Oct 17, 2024
1 parent f64bcd5 commit cb23c4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[![Github Releases (by Release)](https://img.shields.io/github/downloads/shenwei356/csvtk/v0.31.0/total.svg)](https://github.com/shenwei356/csvtk/releases/tag/v0.31.0)
- `csvtk sort/join`:
- faster speed and lower memory.
- `csvtk sort`:
- do not panic for empty input. [#287](https://github.com/shenwei356/csvtk/issues/287)
- `csvtk summary`:
- fix the order of columns. [#282](https://github.com/shenwei356/csvtk/issues/282)
- `csvtk rename2`:
Expand Down
6 changes: 5 additions & 1 deletion csvtk/cmd/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ var sortCmd = &cobra.Command{
}

if len(data) == 0 {
checkError(fmt.Errorf("no data to sort"))
log.Warningf("no data to sort from file: %s", file)
if len(headerRow) > 0 && !config.NoOutHeader {
checkError(writer.Write(headerRow))
}
return
}

// checking keys
Expand Down

0 comments on commit cb23c4f

Please sign in to comment.