0

I hope someone can help me solve the problem I am currently facing with excel. I have been trying to export a csv file I wrote in Excel Ver 16 into R studio but it keeps giving the "incomplete final line found by readTableHeader on 'Book1.csv'" error. I have included the screen shot of the error and the files I had used for this. This doesnt seem to happen for the other data set I downloaded directly from Kaggle called "adult-test.csv" though.

I have tried everything from reinstalling R, R studio, Excel, I even resorted to using Google Sheets and it still doesn't work. If anyone knows what I am doing wrong please do help!

Image of my R studio code

Picture of the csv file I am failing to read

  • Please add data as shown [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for better "help". Also add what has already failed, pictures are not searchable and/or copy-pastable which affects reproducibility. – NelsonGon Jul 01 '20 at 10:13

1 Answers1

0

Hard to guess here.

Sometimes Excel saves csv files incorrectly - even though cells below your table are empty Excel saves them in the csv because maybe in the past, there was something written in there.

So, here is a suggestion

  1. Maybe try to read the Excel file directly, not save it first as a csv. You can do that for example with read.xlsx() from the openxlsx package.
  2. If that does not help, please open the csv file with a text editor (not with Excel again). You will then be able to see the actual problem and if necessary, post the text here (instead of the Excel screenshot)
Georgery
  • 7,643
  • 1
  • 19
  • 52
  • I tried opening it in the text editor and hit enter at the very end of my last cell and it was able to read the file successfully.However, I still cannot triangulate the exact problem and find it slightly confused but at least it works now. Thank you! – Lee Wai Shun Dan Jul 02 '20 at 11:06
  • Cool, that it worked for you. Maybe try to read directly from the csv file. Also, if you think, the answer helped, consider marking it as the answer and maybe give it an upvote. – Georgery Jul 02 '20 at 11:10