read_dm_blaise: Read in Blaise data models

Description Usage Arguments Details Value See Also Examples

View source: R/read_dm_blaise.R

Description

Read in Blaise data models

Usage

1
read_dm_blaise(filename, datafilename = NA)

Arguments

filename

the filename of the file containing the data model.

datafilename

the filename of the data file to which the data model belongs.

Details

The function reads the data model from file and returns a list that can be used by laf_open to open the file for reading. Only a subset of the most common features found in Blaise files are supported. If part of the data model can not be parsed a warning is given.

Value

Returns a data model (which is a list containing all the relevant information to open a file using laf_open. When the file contains more than one data model a list of data models is returned and a warning issued.

See Also

See write_dm to write the data model to file. The data models can be used to open a file using laf_open.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Create some temporary files
tmpdat <- tempfile(fileext="dat")
tmpbla <- tempfile(fileext="bla")

# Generate test data
lines <- c(
    " 1M 1.45Rotterdam ",
    " 2F12.00Amsterdam ",
    " 3  .22 Berlin    ",
    "  M22   Paris     ",
    " 4F12345London    ",
    " 5M     Copenhagen",
    " 6M-12.1          ",
    " 7F   -1Oslo      ")
writeLines(lines, con=tmpdat)

# Create a file containing the data model
writeLines(c( 
    "DATAMODEL test", 
    "FIELDS", 
    "  id     : INTEGER[2]", 
    "  gender : STRING[1]", 
    "  x      : REAL[5] {comment}", 
    "  city   : STRING[10]", 
    "ENDMODEL"), con=tmpbla)
model <- read_dm_blaise(tmpbla, datafilename=tmpdat)
laf <- laf_open(model)

# Cleanup
file.remove(tmpbla)
file.remove(tmpdat)

LaF documentation built on March 26, 2020, 6:59 p.m.