Description Usage Arguments Examples
Reads PGN files into database table
1 | read.pgn.db(con, batch.size = 10^6, conn, table.name = "pgn", ...)
|
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. |
conn |
connection argument created by dbConnect |
table.name |
string (default "pgn"), table name, used in dbWriteTable(conn, table.name, read.pgn(batch)) |
... |
further arguments passed directly to read.pgn() function (besides ignore.other.games and big.mode) |
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 | f <- system.file("extdata", "Carlsen.gz", package = "bigchess")
con <- gzfile(f,"rbt",encoding = "latin1")
require(RSQLite)
conn <- dbConnect(SQLite())
read.pgn.db(con,stat.moves = FALSE,conn = conn)
dbGetQuery(conn, "SELECT COUNT(*) FROM pgn") #2410
dbDisconnect(conn)
# 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")
read.pgn.db(con,conn = conn)
# 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")
read.pgn.db(con,conn = conn)
# Windows (example of zipped file handling)
unzf <- unzip("zipped_pgn_file.zip")
read.pgn.db(con,conn = conn)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.