The csv-validator Reference Manual

This is the csv-validator Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 16:10:16 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 csv-validator

Validates tabular CSV data using predefined validations, similar to its Python counterpart ’Great Expectations’.

Author

Koen van den Berg <>

Home Page
Source Control

(GIT https://github.com/KoenvdBerg/csv-validator)

Bug Tracker
License

BSD-3

Version

1.0.0

Dependencies
  • local-time (system).
  • lparallel (system).
  • parse-float (system).
Source

csv-validator.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 csv-validator/src

Source

csv-validator.asd.

Parent Component

csv-validator (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 csv-validator/csv-validator.asd

Source

csv-validator.asd.

Parent Component

csv-validator (system).

ASDF Systems

csv-validator.


4.1.2 csv-validator/src/packages.lisp

Source

csv-validator.asd.

Parent Component

src (module).

Packages

csv-validator.


4.1.3 csv-validator/src/main.lisp

Dependency

packages.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Public Interface

validate-csv (function).


4.1.4 csv-validator/src/parallel.lisp

Dependency

main.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Internals

4.1.5 csv-validator/src/output.lisp

Dependency

parallel.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Internals

4.1.6 csv-validator/src/csv.lisp

Dependency

output.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Internals

4.1.7 csv-validator/src/validator.lisp

Dependency

csv.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Internals

4.1.8 csv-validator/src/validation_utils.lisp

Dependency

validator.lisp (file).

Source

csv-validator.asd.

Parent Component

src (module).

Public Interface

5 Packages

Packages are listed by definition order.


5.1 csv-validator

Source

packages.lisp.

Use List

common-lisp.

Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Ordinary functions

Function: check-compare-two-dates (x y)

Checks if the incoming date string x is before y

returns
—-
nil if x > y
t if x < y or either x or y not date parsable

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-date-before-today (x)

Checks if the incoming string is a date that is before today

returns
—-
nil if x is parsable and not before today
t if x ain’t parsable or before today

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-date-parsable (x)

Checks if the incoming string is parsable as a date.

returns
—-
date-object if parsable, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-float-string (x)

Checks if the incoming string is a float

returns
—-
t if float, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-integer-in-range (x range-start range-end)

Checks if the incoming string is an integer between range-start and range-end. If no range-start, checks if x < range-end. If no range-end, checks x > range-start.

returns
—-
nil if x outside of range
t if x isn’t integer or within range

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-integer-string (x)

Checks if the incoming string is an integer

returns
—-
t if integer, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-not-null (x)

Checks if the incoming string is not null or null-like

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-null (x)

Checks if the incoming string can be considered null or null-like

returns
—-
t if null, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-number-in-range (x range-start range-end)

Checks if the incoming string is a number between range-start and range-end. If no range-start, checks if x < range-end. If no range-end, checks x > range-start.

returns
—-
nil if x outside of range
t if x isn’t integer or within range

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-number-string (x)

Checks in the incoming string is either an integer or a float

returns
—-
t if number, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-scientific-number-string (x)

Checks if the incoming string is a scientific number

returns
—-
t if float, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: check-tz-parsable (x)

Checks if the incoming string is parsable as a timezone date.

returns
—-
date-object if parsable, else nil

Package

csv-validator.

Source

validation_utils.lisp.

Function: validate-csv (in outdir validation-suite &key threads delim)

Main function that is used to apply the csv-validator to a dataset

args
—-
in: string, filepath to the input csv file
outdir: string, filepath to the output directory where the results will be stored validation-suite: the suite to use to validate the input csv to
threads: integer, indicates the amount of threads to use. Best is between 1-4 delim: character, the csv delimiter

returns
—-
nil

Package

csv-validator.

Source

main.lisp.


6.2 Internals


6.2.1 Ordinary functions

Function: add-index-to-file (infile delim outdir)

Adds an index column to the infile at column position 0 with correct delimiter (first column)

Package

csv-validator.

Source

output.lisp.

Function: cleanup-outdir (outdir)

Cleans up the outdir

Package

csv-validator.

Source

output.lisp.

Function: get-col-position (col-name cols)

Obtains the position of a column name in a list of columns

args
—-
col-name: string, describes the column name
cols: list(string), list of column names to find the position in

returns
—-
int column position

Package

csv-validator.

Source

validator.lisp.

Function: get-header-row (infile delim)

Obtains the header row from the infile

args
—-
infile: string, filepath to the input csv file delim: character, the csv delimiter

returns
—-
header row as a list. E.g. ’("header1" "header2")

Package

csv-validator.

Source

validator.lisp.

Function: get-values (header spec record)

Obtains the values from a record based on the depends field in the
validation suite

args
—-
header: list(string), list that contains the headers as strings
spec: a single specification of a validation suite as a list
record: list(string), list that holds the values of that record. Every value is string.

returns
—-
list of values

Package

csv-validator.

Source

validator.lisp.

Function: init (threads)

Initializes the lparallel kernel

Package

csv-validator.

Source

parallel.lisp.

Function: join-files-together (filepaths outdir)

Appends multiple csv files together vertically to new file called errors.csv

Package

csv-validator.

Source

output.lisp.

Function: list-dir (outdir &optional prefix)

List files in specified outdir that have wildcard prefix

Package

csv-validator.

Source

output.lisp.

Function: move-working-dir (target-dir)

Move the workind directory to target-dir

Package

csv-validator.

Source

output.lisp.

Function: run-record-validation (in outdir header suite delim)

Main function for validating a single csv infile in 1 thread

args
—-
in: string, filepath to the input csv file
outdir: string, filepath to the output directory where the results will be stored suite: the suite to use to validate the input csv to
delim: character, the csv delimiter

returns
—-
nil

Package

csv-validator.

Source

validator.lisp.

Function: shutdown ()

Shuts down the kernel

Package

csv-validator.

Source

parallel.lisp.

Function: split-file-in-n (nr-files infile outdir)

Splits the tabular infile in N=nr-files splits that can be processed individually

Package

csv-validator.

Source

output.lisp.

Function: split-string (separator str)

Splits a string using the given separator, returns a list with the substrings.

args
—-
separator: character, char that is used to split the input csv with
str: string, the input string that will be split

returns
—-
list with elements between delimiter

example
—-
name;age;gender –> ("name" "age" "gender")

Package

csv-validator.

Source

csv.lisp.

Function: to-record (elements)

Converts a sequence of elements into a record.

Package

csv-validator.

Source

csv.lisp.

Function: validate-header (header suite)

Validates the header against the expectation suite. Filters the expectation suite so that only the specifications remain that are also present in the header.

args
—-
header: list(string), list that contains the headers as strings suite: the suite to use to validate the input csv to

returns
—-
suite but then filtered so that it contains only the specs that are also in header

Package

csv-validator.

Source

validator.lisp.

Function: validate-record (vals spec)

Validates record-values based on the logic defined in a single specification of a validation suite

args
—-
vals: list(string), list of values. Every value is string spec: a single specification of a validation suite as a list

returns
—-
t if logic holds, else nil

Package

csv-validator.

Source

validator.lisp.

Function: write-header-validation-file (missing-header outdir)

writes the validation file that contains the missing headers. A missing header is a column that was defined in the validation-suite, but couldn’t be found back in the input csv

args
—-
missing-header: list, contains each spec of the validation
suite that couldn’t be found back in the input csv file
outdir: string, filepath to the output directory where the results will be stored

returns
—-
string, filepath to the header validation file

Package

csv-validator.

Source

output.lisp.

Function: write-record-to-stream (str index spec vals)

Writes the result of a record-validation to an output file

args
—-
str: stream, output stream
index: string, the index (row number) of the input csv
spec: list, a single specification of a validation suite as a list vals: list(string), the values that are relevant for this result

returns
—-
nil

Package

csv-validator.

Source

output.lisp.

Function: write-result-file (missing-header outdir)

Writes individual validation result files and combines them together.

args
—-
outdir: string, filepath to the output directory where the results will be stored
missing-header: a list that contains each spec of the validation

returns
—-
string, filepath to the final result file that contains all validations

Package

csv-validator.

Source

output.lisp.

Function: write-result-header-file (outdir)

Writes the header row of the validation result file. This is being done here so that the csv-validator can be run in parallel without having to keep the csv header of each output into account.

args
—-
outdir: string, filepath to the output directory where the results will be stored

returns
—-
string, filepath to the file that contains the header row

Package

csv-validator.

Source

output.lisp.


6.2.2 Types

Type: record ()

record type.

Package

csv-validator.

Source

csv.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   C   F   G   I   J   L   M   R   S   T   V   W  
Index Entry  Section

A
add-index-to-file: Private ordinary functions

C
check-compare-two-dates: Public ordinary functions
check-date-before-today: Public ordinary functions
check-date-parsable: Public ordinary functions
check-float-string: Public ordinary functions
check-integer-in-range: Public ordinary functions
check-integer-string: Public ordinary functions
check-not-null: Public ordinary functions
check-null: Public ordinary functions
check-number-in-range: Public ordinary functions
check-number-string: Public ordinary functions
check-scientific-number-string: Public ordinary functions
check-tz-parsable: Public ordinary functions
cleanup-outdir: Private ordinary functions

F
Function, add-index-to-file: Private ordinary functions
Function, check-compare-two-dates: Public ordinary functions
Function, check-date-before-today: Public ordinary functions
Function, check-date-parsable: Public ordinary functions
Function, check-float-string: Public ordinary functions
Function, check-integer-in-range: Public ordinary functions
Function, check-integer-string: Public ordinary functions
Function, check-not-null: Public ordinary functions
Function, check-null: Public ordinary functions
Function, check-number-in-range: Public ordinary functions
Function, check-number-string: Public ordinary functions
Function, check-scientific-number-string: Public ordinary functions
Function, check-tz-parsable: Public ordinary functions
Function, cleanup-outdir: Private ordinary functions
Function, get-col-position: Private ordinary functions
Function, get-header-row: Private ordinary functions
Function, get-values: Private ordinary functions
Function, init: Private ordinary functions
Function, join-files-together: Private ordinary functions
Function, list-dir: Private ordinary functions
Function, move-working-dir: Private ordinary functions
Function, run-record-validation: Private ordinary functions
Function, shutdown: Private ordinary functions
Function, split-file-in-n: Private ordinary functions
Function, split-string: Private ordinary functions
Function, to-record: Private ordinary functions
Function, validate-csv: Public ordinary functions
Function, validate-header: Private ordinary functions
Function, validate-record: Private ordinary functions
Function, write-header-validation-file: Private ordinary functions
Function, write-record-to-stream: Private ordinary functions
Function, write-result-file: Private ordinary functions
Function, write-result-header-file: Private ordinary functions

G
get-col-position: Private ordinary functions
get-header-row: Private ordinary functions
get-values: Private ordinary functions

I
init: Private ordinary functions

J
join-files-together: Private ordinary functions

L
list-dir: Private ordinary functions

M
move-working-dir: Private ordinary functions

R
run-record-validation: Private ordinary functions

S
shutdown: Private ordinary functions
split-file-in-n: Private ordinary functions
split-string: Private ordinary functions

T
to-record: Private ordinary functions

V
validate-csv: Public ordinary functions
validate-header: Private ordinary functions
validate-record: Private ordinary functions

W
write-header-validation-file: Private ordinary functions
write-record-to-stream: Private ordinary functions
write-result-file: Private ordinary functions
write-result-header-file: Private ordinary functions


A.3 Variables


A.4 Data types