0

I had troubles importing data I need from .csv files to R.
So to check, I created a simple .csv from excel with 2 columns and 3 rows - it reads like this in notepad

what,now
1,4
2,5
3,6

When I try import this data into R

d <- read.csv("D:/Book1.csv")

it gives a warning message,

Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'D:/Book1.csv'

and then when I view the data, it's some gibberish.

What do I do?

Arun kumar mahesh
  • 2,289
  • 2
  • 14
  • 22
  • 4
    Did you try to search the error message? First hit leads me to this https://stackoverflow.com/questions/5990654/incomplete-final-line-warning-when-trying-to-read-a-csv-file-into-r Did you try any of the method listed there? – Ronak Shah Jun 14 '19 at 07:35
  • 2
    Open the file with Notepad++ or evem MS Notebook, go to the end of last line of you file and tap enter. And as it mentioned above `sep=","` – Adamm Jun 14 '19 at 07:39
  • If you are saving the file using notepad then add newline(press enter) after last data (i.e. after 6) and save. If you are saving the file using excel then use save As and select option `CSV (Comma delimeted) (*.csv)` as file type – Kushdesh Jun 14 '19 at 08:26
  • I am using excel and saving the file as .csv – JRBatHolmes Jun 14 '19 at 10:53
  • @Ronak Yes, I tried leaving the last line empty and having the data in a new csv . none of these solutions work – JRBatHolmes Jun 14 '19 at 10:55

1 Answers1

0

I was using a work PC, and the files were encrypted - which was the reason why importing data into R was not working. I bypassed it by copying data into a text document. Thanks everyone!