Skip to content

add header and skip to sample_lines#14

Open
VincentGuyader wants to merge 2 commits intodjvanderlaan:masterfrom
VincentGuyader:master
Open

add header and skip to sample_lines#14
VincentGuyader wants to merge 2 commits intodjvanderlaan:masterfrom
VincentGuyader:master

Conversation

@VincentGuyader
Copy link
Copy Markdown

@VincentGuyader VincentGuyader commented Apr 26, 2018

I used the sample_lines function to create a read_csv_sampled function. the goal is to be sure to correctly deal with header, and to allow skiping some rowd in the file.

read_csv_sampled <- function(file,size=100, header = TRUE, sep = ",", 
                             dec = ".",nlines=NULL,skip=0, ...){
   
  first_row <- readLines(file,n = 1+ skip)
  tirage <- sample_lines(file, n = size,
                         nlines = nlines,
                         skip = skip,
                         header = header)
  if (header){
  info <- c(first_row,tirage)
    }else{
   info <- tirage
  }
  
  
    read.table(text=info, header = header, sep = sep, dec = dec, ...)

}```

I can add more unit test if you want.

Regards

@djvanderlaan
Copy link
Copy Markdown
Owner

Hi @VincentGuyader , it has been almost a century ago that you made this pull request. Sorry for not getting back to you on this. I like the idea. Are you willing (after all this time) to follow up on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants