In Python:
fo = open("foo.txt", "r+")
str = fo.read(10);
position = fo.tell();
print "Current file position : ", position
Is there a file pointer in R? Can I know where the current file position is while I read the file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well to look at file-related functions you can try
?filewhich tells you how to open a file and many file-related functions.fois a connection object that can be fed to other functions.I recommend you read all of
?file, which is very informative.In particular, see the
See AlsoandExamplessections.In the
See Alsosection are listed a set of related functions for working with files.In here it mentions (for example)
readLines,readBin(to read binary files),scan(to read data into a vector or list) for reading files.It also mentions
seek. Looking at?seekyou will see thatSo try
(Tip – the help files in R are very helpful! The ‘See Also’ section will tell you functions related to the one you are looking at, and the ‘Examples’ section will give you examples of how to use them. If you wanted to look up stuff to do with files and
?filedidn’t work, you could always do??filewhich does a fuzzy search).