|
1 |
| -VERSION < v"0.7-" && __precompile__() |
2 |
| - |
3 | 1 | module SASLib
|
4 | 2 |
|
5 |
| -using StringEncodings, Missings, Compat.Dates, Compat.Distributed, Compat |
| 3 | +using StringEncodings |
6 | 4 | using TabularDisplay
|
| 5 | +using Dates |
7 | 6 |
|
8 | 7 | export readsas, REGULAR_STR_ARRAY
|
9 | 8 |
|
@@ -66,8 +65,7 @@ read the entire file content. When called again, fetch the next `nrows` rows.
|
66 | 65 | function read(handler::Handler, nrows=0)
|
67 | 66 | # println("Reading $(handler.config.filename)")
|
68 | 67 | elapsed = @elapsed result = read_chunk(handler, nrows)
|
69 |
| - # TODO base keyword arg should not be needed due to Compat.jl issue #567 |
70 |
| - elapsed = Compat.round(elapsed; digits = 5, base = 10) |
| 68 | + elapsed = round(elapsed, digits = 5) |
71 | 69 | println1(handler, "Read $(handler.config.filename) with size $(size(result, 1)) x $(size(result, 2)) in $elapsed seconds")
|
72 | 70 | return result
|
73 | 71 | end
|
|
186 | 184 | return handler.cached_page[offset+1:offset+len] #offset is 0-based
|
187 | 185 | # => too conservative.... we expect cached_page to be filled before this function is called
|
188 | 186 | # if handler.cached_page == []
|
189 |
| - # Compat.@warn("_read_byte function going to disk") |
| 187 | + # @warn("_read_byte function going to disk") |
190 | 188 | # seek(handler.io, offset)
|
191 | 189 | # try
|
192 | 190 | # return Base.read(handler.io, len)
|
@@ -275,14 +273,14 @@ function read_header(handler)
|
275 | 273 | else
|
276 | 274 | handler.file_encoding = FALLBACK_ENCODING # hope for the best
|
277 | 275 | handler.config.verbose_level > 0 &&
|
278 |
| - Compat.@warn("Unknown file encoding value ($buf), defaulting to $(handler.file_encoding)") |
| 276 | + @warn("Unknown file encoding value ($buf), defaulting to $(handler.file_encoding)") |
279 | 277 | end
|
280 | 278 | #println2(handler, "file_encoding = $(handler.file_encoding)")
|
281 | 279 |
|
282 | 280 | # User override for encoding
|
283 | 281 | if handler.config.encoding != ""
|
284 | 282 | handler.config.verbose_level > 0 &&
|
285 |
| - Compat.@warn("Encoding has been overridden from $(handler.file_encoding) to $(handler.config.encoding)") |
| 283 | + @warn("Encoding has been overridden from $(handler.file_encoding) to $(handler.config.encoding)") |
286 | 284 | handler.file_encoding = handler.config.encoding
|
287 | 285 | end
|
288 | 286 | # println2(handler, "Final encoding = $(handler.file_encoding)")
|
@@ -405,7 +403,7 @@ function check_user_column_types(handler)
|
405 | 403 | # check column_types
|
406 | 404 | for k in keys(handler.config.column_types)
|
407 | 405 | if !case_insensitive_in(k, handler.column_symbols)
|
408 |
| - Compat.@warn("Unknown column symbol ($k) in column_types. Ignored.") |
| 406 | + @warn("Unknown column symbol ($k) in column_types. Ignored.") |
409 | 407 | end
|
410 | 408 | end
|
411 | 409 | end
|
@@ -613,7 +611,7 @@ function _process_columnsize_subheader(handler, offset, length)
|
613 | 611 | offset += int_len
|
614 | 612 | handler.column_count = _read_int(handler, offset, int_len)
|
615 | 613 | if (handler.col_count_p1 + handler.col_count_p2 != handler.column_count)
|
616 |
| - Compat.@warn("Warning: column count mismatch ($(handler.col_count_p1) + $(handler.col_count_p2) != $(handler.column_count))") |
| 614 | + @warn("Warning: column count mismatch ($(handler.col_count_p1) + $(handler.col_count_p2) != $(handler.column_count))") |
617 | 615 | end
|
618 | 616 | end
|
619 | 617 |
|
@@ -833,13 +831,13 @@ end
|
833 | 831 | function read_chunk(handler, nrows=0)
|
834 | 832 |
|
835 | 833 | if !isdefined(handler, :column_types)
|
836 |
| - Compat.@warn("No columns to parse from file") |
| 834 | + @warn("No columns to parse from file") |
837 | 835 | return ResultSet()
|
838 | 836 | end
|
839 | 837 | # println("column_types = $(handler.column_types)")
|
840 | 838 |
|
841 | 839 | if handler.row_count == 0
|
842 |
| - Compat.@warn("File has no data") |
| 840 | + @warn("File has no data") |
843 | 841 | return ResultSet()
|
844 | 842 | end
|
845 | 843 |
|
|
971 | 969 |
|
972 | 970 | # convert Float64 value into Date object
|
973 | 971 | function date_from_float(x::Vector{Float64})
|
974 |
| - @compat v = Vector{Union{Date, Missing}}(undef, length(x)) |
| 972 | + v = Vector{Union{Date, Missing}}(undef, length(x)) |
975 | 973 | for i in 1:length(x)
|
976 | 974 | v[i] = isnan(x[i]) ? missing : (sas_date_origin + Dates.Day(round(Int64, x[i])))
|
977 | 975 | end
|
|
980 | 978 |
|
981 | 979 | # convert Float64 value into DateTime object
|
982 | 980 | function datetime_from_float(x::Vector{Float64})
|
983 |
| - @compat v = Vector{Union{DateTime, Missing}}(undef, length(x)) |
| 981 | + v = Vector{Union{DateTime, Missing}}(undef, length(x)) |
984 | 982 | for i in 1:length(x)
|
985 | 983 | v[i] = isnan(x[i]) ? missing : (sas_datetime_origin + Dates.Second(round(Int64, x[i])))
|
986 | 984 | end
|
@@ -1040,7 +1038,7 @@ function convert_column_type_if_needed!(handler, rslt, name)
|
1040 | 1038 | try
|
1041 | 1039 | rslt[name] = convert(Vector{type_wanted}, rslt[name])
|
1042 | 1040 | catch ex
|
1043 |
| - Compat.@warn("Unable to convert column to type $type_wanted, error=$ex") |
| 1041 | + @warn("Unable to convert column to type $type_wanted, error=$ex") |
1044 | 1042 | end
|
1045 | 1043 | end
|
1046 | 1044 | end
|
@@ -1587,13 +1585,13 @@ function populate_column_indices(handler)
|
1587 | 1585 | if inflag && length(processed) != length(handler.config.include_columns)
|
1588 | 1586 | diff = setdiff(handler.config.include_columns, processed)
|
1589 | 1587 | for c in diff
|
1590 |
| - Compat.@warn("Unknown include column $c") |
| 1588 | + @warn("Unknown include column $c") |
1591 | 1589 | end
|
1592 | 1590 | end
|
1593 | 1591 | if exflag && length(processed) != length(handler.config.exclude_columns)
|
1594 | 1592 | diff = setdiff(handler.config.exclude_columns, processed)
|
1595 | 1593 | for c in diff
|
1596 |
| - Compat.@warn("Unknown exclude column $c") |
| 1594 | + @warn("Unknown exclude column $c") |
1597 | 1595 | end
|
1598 | 1596 | end
|
1599 | 1597 | # println2(handler, "column_indices = $(handler.column_indices)")
|
|
0 commit comments