module DateColumnAudit
Overview
Inspect ONE column of a CSV and sort every value into a date shape class. Shape only: it cannot tell whether an ambiguous value is day first or month first, and it does not read time zones. The clock is never read.
Defined in:
date_column_audit.crConstant Summary
-
AMBIGUOUS =
"ambiguous day/month" -
CLASSES =
[ISO_DATE, ISO_IMPOSSIBLE, ISO_TIME, DAY_FIRST, MONTH_FIRST, AMBIGUOUS, IMPOSSIBLE_SLASH, OTHER] -
DAY_FIRST =
"day first" -
IMPOSSIBLE_SLASH =
"impossible day/month" -
ISO_DATE =
"yyyy-mm-dd" -
ISO_IMPOSSIBLE =
"yyyy-mm-dd impossible" -
ISO_RE =
/\A([0-9]{4})-([0-9]{2})-([0-9]{2})\z/ -
ISO_TIME =
"yyyy-mm-dd HH:mm[:ss]" -
MIXABLE =
[ISO_DATE, ISO_TIME, DAY_FIRST, MONTH_FIRST] -
MONTH_FIRST =
"month first" -
OTHER =
"other text" -
SLASH_RE =
/\A([0-9]{1,2})([\/.\-])([0-9]{1,2})\2([0-9]{4})\z/ -
TIME_RE =
/\A([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2})(?::([0-9]{2}))?\z/ -
USAGE =
"usage: date-column-audit file.csv --column NAME\nShape check of one column: it cannot tell whether an ambiguous value is day first or month first, and it does not read time zones. More: https://www.onegtmlab.dev/tool-directory/verification/zerobounce" -
VERSION =
"1.0.0"
Class Method Summary
-
.audit(text : String, column : String) : Report
Reads the CSV text and audits the column named by
column. -
.classify(value : String) : String
One trimmed, non-empty value gets exactly one class.
-
.cli(args : Array(String), stdout : IO, stderr : IO) : Int32
Exit codes: 0 no problems, 1 problems found, 2 unreadable file, unknown column, missing --column, unknown option or empty input.
- .days_in_month(y : Int32, m : Int32) : Int32
- .leap?(y : Int32) : Bool
-
.parse_csv(text : String) : Array(Array(String))
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark.
- .pct(count : Int32, whole : Int32) : String
- .real_date?(y : Int32, m : Int32, d : Int32) : Bool
- .real_time?(h : Int32, mi : Int32, s : Int32) : Bool
- .render(r : Report) : String
- .table(rows : Array(Array(String))) : String
Class Method Detail
Reads the CSV text and audits the column named by column.
Exit codes: 0 no problems, 1 problems found, 2 unreadable file, unknown column, missing --column, unknown option or empty input.
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.