Skip to content

Commit

Permalink
Merge pull request #2 from ScottPJones/spj/useformat
Browse files Browse the repository at this point in the history
Update to use Format instead of Formatting
  • Loading branch information
HenricoWitvliet authored Mar 7, 2024
2 parents 0c6f111 + 04c85cc commit e7de7b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name = "FWFTables"
uuid = "1acc1471-1fd5-4be2-a8c2-3f3b1db75813"
authors = ["henrico "]
version = "0.1.0"
version = "0.1.1"

[deps]
FixedSizeStrings = "3ca710bb-85d4-534c-9bae-b7b5d9e27e20"
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
FixedSizeStrings = "0.1"
Formatting = "0.4"
Format = "1.3"
Parsers = "1, 2"
Tables = "1.0"
julia = "1.5"
Expand Down
12 changes: 5 additions & 7 deletions src/FWFTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module FWFTables

import Tables
import Parsers
import Formatting
import Format
import FixedSizeStrings.FixedSizeString

export readbla, Varspec, FWFTable, File, write
Expand Down Expand Up @@ -292,15 +292,13 @@ end

makewrite(::Type{FixedSizeString}, spec) = (io, val) -> Base.write(io, Ref(val))
function makewrite(::Type{Union{Missing, Int64}}, spec)
fs = "0>" * string(spec.length) * "d"
fe = Formatting.FormatSpec(fs)
fe = Format.FormatSpec(string("0>", spec.length, "d"))
spaces = repeat(" ", spec.length)
return (io, val) -> ismissing(val) ? spaces : Formatting.printfmt(io, fe, val)
return (io, val) -> ismissing(val) ? spaces : Format.printfmt(io, fe, val)
end
function makewrite(::Type{Float64}, spec)
fs = "0>" * string(spec.length) * "." * string(spec.decimals) * "f"
fe = Formatting.FormatSpec(fs)
return (io, val) -> Formatting.printfmt(io, fe, val)
fe = Format.FormatSpec(string("0>", spec.length, ".", spec.decimals, "f"))
return (io, val) -> Format.printfmt(io, fe, val)
end
function makewrite(::Type{Nothing}, spec)
spaces = repeat(" ", spec.length)
Expand Down

0 comments on commit e7de7b2

Please sign in to comment.