Skip to content

Instantly share code, notes, and snippets.

@mike-lawrence
Created May 11, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-lawrence/e9dda708a8ad648980ce4af6c71c0757 to your computer and use it in GitHub Desktop.
Save mike-lawrence/e9dda708a8ad648980ce4af6c71c0757 to your computer and use it in GitHub Desktop.
Find the last line of a big text file in R
f = file(description='bigFile.txt',open='rb')
n = 0
temp = 1
while(length(temp)<2){
n = n + 1
seek(con=f,origin='end',where=-(2^n))
temp <- scan(f,what='character',quiet=T)
}
last_line = temp[2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment