Created
May 11, 2017 17:35
-
-
Save mike-lawrence/e9dda708a8ad648980ce4af6c71c0757 to your computer and use it in GitHub Desktop.
Find the last line of a big text file in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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