Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incomplete final line found error when reading url using readLines() in R

Tags:

r

web-scraping

I am trying to read the html content of a url using the readLines() function in R. However, I am getting a "incomplete final line found" warning message as shown below? How can I skip the final line in such a case? Any suggestions would be very much appreciated.

x <- readLines("https://in.finance.yahoo.com/industries/technology")

Warning message:
In readLines("https://in.finance.yahoo.com/industries/technology") :
  incomplete final line found on 'https://in.finance.yahoo.com/industries/technology'
like image 915
Code_Sipra Avatar asked Nov 17 '17 18:11

Code_Sipra


1 Answers

Most files are missing an End of Line marker like a new line below, so I would just use warn=FALSE.

cat("abc\ndef\nhij", file="test.txt")
readLines( "test.txt")
# [1] "abc" "def" "hij"
# Warning message:
# In readLines("test.txt") : incomplete final line found on 'test.txt'
readLines( "test.txt", warn=FALSE)
# [1] "abc" "def" "hij"
like image 106
Chris S. Avatar answered Sep 20 '22 02:09

Chris S.