Skip to content

Commit

Permalink
CSV formatter now writes in decimal format rather than scientific not…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
TomWright committed Oct 18, 2022
1 parent a574326 commit c99b8cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet

## [v1.27.2] - 2022-10-18

### Fixed

- Help text for select and delete commands now contain all available parsers.
- Errors now implement the `Is` interface so they are easier to use from go.
- Floats are now formatted in decimal format instead of scientific notification when writing to CSV ([Issue 245](https://github.com/TomWright/dasel/issues/245), [Issue 229](https://github.com/TomWright/dasel/issues/229))

## [v1.27.1] - 2022-09-28

Expand Down Expand Up @@ -491,7 +496,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Everything!

[unreleased]: https://github.com/TomWright/dasel/compare/v1.27.1...HEAD
[unreleased]: https://github.com/TomWright/dasel/compare/v1.27.2...HEAD
[v1.27.2]: https://github.com/TomWright/dasel/compare/v1.27.1...v1.27.2
[v1.27.1]: https://github.com/TomWright/dasel/compare/v1.27.0...v1.27.1
[v1.27.0]: https://github.com/TomWright/dasel/compare/v1.26.1...v1.27.0
[v1.26.1]: https://github.com/TomWright/dasel/compare/v1.26.0...v1.26.1
Expand Down
7 changes: 6 additions & 1 deletion storage/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ func (p *CSVParser) toBytesHandleDoc(writer *csv.Writer, doc *CSVDocument) error
if !ok {
val = ""
}
values = append(values, fmt.Sprint(val))
switch val.(type) {
case float32, float64:
values = append(values, fmt.Sprintf("%f", val))
default:
values = append(values, fmt.Sprint(val))
}
}

if err := writer.Write(values); err != nil {
Expand Down

0 comments on commit c99b8cc

Please sign in to comment.