I would suggest that you also try the following code:
tab5rows <- read.table("datatable.txt", header = TRUE, nrows = 5)
classes <- sapply(tab5rows, class)
tabAll <- read.table("datatable.txt", header = TRUE, colClasses = classes)
Discussed in detail here can significantly improve the speed of reading big files. More importantly, first line would enable you to look inside the file. If you can open it the scope for manoeuvre is large. Alternatively, it can be worthwhile to read file in binary:
messy_file <- readLines(file("ProblematicData.csv", "rb"), encoding="UTF-8", skipNul=TRUE)
Edit
In addition, I would suggest that you have a look at this discussion where some options for reading big files are discussed in detail.
My approach to the problem would be:
- Try first option with
read.table
, alternatively
- Try
fread
from the data.table
, alternatively
- Read as binary