read.pgn.ff: Reads PGN files into ff data frame

Description Usage Arguments Value Examples

View source: R/read.pgn.ff.R

Description

Reads PGN files into ff data frame

Usage

1
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

 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
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)

bigchess documentation built on Aug. 5, 2020, 5:09 p.m.