2

I’ trying to read in a set of data tables. All of which is representing different parts of a larger Excel table, selected using ”filter” and saved individually as a .csv file. Most of my tables have 5 rows of data but two of them have 4 rows. The tables with 5 rows of data reads in to R as requested:

Y <- read.csv(file = "MyFile.csv", row.names = 1,header = T, sep = ";") 

No problem.

The tables with 4 rows of data gives following error meassage:

In read.csv("MyFile.csv", quote = "", : incomplete final line found by readTableHeader on ' MyFile.csv'

It’s the same problem with

Z <- read.table("MyFile.csv", quote = "", sep = ';', header = TRUE)

There is no missing data in the file. When I print the Y or Z object in R no missing data is visible (or invisible as it were).

I know the problem is extremely simple, but as I’ve got frustration pouring out of my ears my officemates would really appreciate your help.

joran
  • 169,992
  • 32
  • 429
  • 468
Pernille
  • 21
  • 1
  • 3
  • I guess one typo is sep = ";". Replace this with sep = ",". – MYaseen208 Oct 16 '11 at 23:32
  • Possible [duplicate](http://stackoverflow.com/questions/5990654/incomplete-final-line-warning-when-trying-to-read-a-csv-file-into-r)? – joran Oct 16 '11 at 23:36
  • That would not help as the separator is ";" and not "," – Pernille Oct 16 '11 at 23:47
  • Not quite a duplicate joran as I don't have missing data or unequal lengths of my columns. However, I could see that readTableHeader reads the first 5 lines of data. Could this be the reason that I get no error when reading in my 5 row data but only my 4 row data sets? – Pernille Oct 16 '11 at 23:56
  • is it an **error** message or a **warning** message? – Ben Bolker Oct 17 '11 at 00:01

1 Answers1

5

The final line of your CSV doesn't have a line feed or carriage return.

Plan A: open the files in a text editor, go to the end of the final line, hit enter and then save the modified file.

Plan B: if there are too many files for Plan A, you could simply ignore the warnings, since the files seem to be loaded fine (apart from that message).

pete
  • 2,327
  • 2
  • 15
  • 23