0

I am working with a big csv file and I am looking for ways to make importing it faster in read.table for the colClasses switch.

Currently I have this function:

getColumnNames <- function (file) {
 system(paste("head -1 ", file), TRUE)
}

this gets the first line of the CSV but in this way:

[1] "\"\",\"p_id\",\"Name\",\"Country\",\"person_degree\",\"person_email_value\"

Is there any way using strsplit or another method to make this in to a vector that can be used for ColClasses to faster the read.table process?

Thanks

2
  • 1
    Have a look at the fread function from package data.table.
    – Roland
    Jul 28, 2014 at 15:22
  • 2
    You could just use read.csv with nrows=1 and header=T. That should be pretty quick and you can just take the names from that.
    – MrFlick
    Jul 28, 2014 at 15:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.