validate_csv: Validate a csv file using an xml file as schema.

View source: R/validate_csv.R

validate_csvR Documentation

Validate a csv file using an xml file as schema.

Description

validate_csv validates a csv file using an xml file as schema, i.e. specifying its column names and value ranges (not yet implemented).

Usage

validate_csv(xmlFileName, csvFileName)

Arguments

xmlFileName

File name of the xml file containing the schema for the csv file.

csvFileName

File name of the csv file to validate.

Details

Return TRUE if the csv file is validated, otherwise, it returns FALSE.

Examples

rootPath <- file.path(system.file(package = "simutils"), "extdata")

# antennas file
csv_fn <- file.path(rootPath, "output_files", "antennas.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "antennas_dict.xml")
validate_csv(xml_fn, csv_fn)

# antennacells_mno1 file
csv_fn <- file.path(rootPath, "output_files", "AntennaCells_MNO1.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "antennaCells_dict.xml")
validate_csv(xml_fn, csv_fn)

# antennainfo_mno_mno1 file
csv_fn <- file.path(rootPath, "output_files", "AntennaInfo_MNO_MNO1.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "events_dict.xml")
validate_csv(xml_fn, csv_fn)

# grid file
csv_fn <- file.path(rootPath, "output_files", "grid.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "grid_dict.xml")
validate_csv(xml_fn, csv_fn)

# Column names Tile ID, Mobile Phone(s) ID are not valid column name
# persons file
csv_fn <- file.path(rootPath, "output_files", "persons.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "persons_dict.xml")
validate_csv(xml_fn, csv_fn)

# signalmeasure_mno1 file
csv_fn <- file.path(rootPath, "output_files", "SignalMeasure_MNO1.csv")
xml_fn <- file.path(rootPath, "metadata/output_files", "SignalMeasure_dict.xml")
validate_csv(xml_fn, csv_fn)


bogdanoancea/simutils documentation built on April 4, 2022, 2:58 p.m.