read.pgn.ff {bigchess}R Documentation

Reads PGN files into ff data frame

Description

Reads PGN files into ff data frame

Usage

read.pgn.ff(con, batch.size = 10^6, ignore.other.games = F, ...)

Arguments

con

connection argument passed directly to readLines() function. String - the name of the file which the data are to be read from or connection object or URL.

batch.size

number of lines to read in one batch, default is 10^6.

ignore.other.games

boolean (default FALSE) if TRUE result is subset of original dataset without games with result marked as "*", i.e. ongoing games. The only one argument which is not passed directly to read.pgn function.

...

further arguments passed directly to read.pgn() function (besides ignore.other.games and big.mode)

Value

ff data frame like from read.pgn() function. Since character values are not supported in ffdf object, "Movetext" column is ommited.

Examples


require(ff)
require(ffbase)
f <- system.file("extdata", "Carlsen.gz", package = "bigchess")
con <- gzfile(f,"rbt",encoding = "latin1")
# options("fftempdir"="/path/"...) # if necessarily
fdf <- read.pgn.ff(con,stat.moves = FALSE)
delete(fdf)
# Works with all types of connections (also gz or zip files).
# con argument is passed directly to readLines(con,batch.size)
# so (if total number of lines to read is greater then batch.size)
# depending on platform use it correctly:
# Windows ('rb' opening mode for loop over readLines):
con <- gzfile(system.file("extdata", "Carlsen.gz", package = "bigchess"),"rb",encoding = "latin1")
# con <- file("path_to_big_chess_file.pgn","rb",encoding = "latin1")
fdf <- read.pgn.ff(con)
delete(fdf)

# Linux/Mac OS X ('r' opening mode for loop over readLines):
con <- gzfile(system.file("extdata", "Carlsen.gz", package = "bigchess"),"r",encoding = "latin1")
# con <- file("path_to_big_chess_file.pgn","r",encoding = "latin1")
fdf <- read.pgn.ff(con)
delete(fdf)

# Windows (example of zipped file handling)
unzf <- unzip("zipped_pgn_file.zip")
fdf <- read.pgn.ff(file(unzf,"rb"))
delete(fdf)


[Package bigchess version 1.9.1 Index]