read_meta: Read csv file with metadata

Description Usage Arguments Value Examples

View source: R/read_meta.R

Description

The function will read four types of csv files.

Embedded metadata

The input file is in the format produced by write_meta_template(...,embedded = TRUE), which has metadata embedded at the top of the file above the data table. File names are typically in the format "fileName_withMeta.csv"

Data file with external metadata

Metadata is stored in an external metadata file located in the same folder as the data file. The function call is to the data file (e.g. read_meta("dataFile.csv")). The function then will read in any metadata located in a file in same folder named "dataFile_meta.csv".

Data file without external metadata

If there is no "dataFile_meta.csv" file associated with the data file located in the folder, the function will read in the data table only and issue a warning that there are no metadata.

Metadata only

If the call is to a "dataFile_meta.csv" metadata file, the function will read in the metadata and issue a warning that there is no data table included in the file. Note that "dataFile.csv" may in fact exist, but the function will not bother to look for it.

Usage

1

Arguments

file

Path and name of the .csv data file to read.

Value

List with three data frames

dGeneralMeta

General metadata with attribute and value

dVariableMeta

Table of metadata for each dataset variable

dData

The dataset

Examples

1
2
iris_withMeta_raw <- read.csv(system.file("iris_withMeta.csv", package = "metacsv" ))
iris_withMeta_parsed <- read_meta(system.file("iris_withMeta.csv", package = "metacsv" ))

pmcelhany/metacsv documentation built on June 3, 2021, 1:36 a.m.