I have some data that looks something like this:
myDat <- data.frame(V1=rnorm(1000),
V2=sample(LETTERS, 1000, replace=TRUE),
V3=sample(1:1000, 1000))
write.table(myDat, file="myData.txt", sep="|", quote=FALSE, col.names=FALSE, row.names=FALSE)
write("00001000 RECORDS", file="myData.txt", append=TRUE) # This is the annoying footer
Note the footer at the bottom that is always there.. I would like to read it in using sqldf. Something like this:
f <- file("myData.txt")
hkFile <- sqldf("SELECT * FROM f", dbname=tempfile(),
file.format=list(header=FALSE, sep="|", eol="\n"))
I keep getting this error because of the footer appended to the data:
Error in .local(conn, name, value, ...) :
RS_sqlite_import: myData.txt line 1001 expected 3 columns of data but found 1
Is there a simple way to get around the footer? Copying the data to a temporary file is not an option since some of my datasets are ~6GB