Function to split big file to a series small files (by row)

split_row_file(filename, each_file_lines = 100, use_system_split = FALSE,
  system_split_params = "_split", write_fun = "write.table",
  write_params_x = "x", write_params_file = "file",
  write_params = list(sep = "", row.names = FALSE, col.names = FALSE, quote =
  FALSE))

Arguments

filename

Filename that need to be split

each_file_lines

Each file row num

use_system_split

Wheather use system split commend

system_split_params

When use_system_split, provide the prefix and other params default is 'split'

write_fun

Function to read data, default is read.table

write_params_x

Parameter name of output object in read.fun

write_params_file

Parameter name of input file in read.fun

write_params

Other parameters pass to write_fun

Examples

dat <- data.frame(col1 = 1:1000) outfn <- tempfile() write.table(dat, outfn, sep = '\t', quote = FALSE, row.names = FALSE) split_row_file(outfn)
#> $`1` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_1" #> #> $`2` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_2" #> #> $`3` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_3" #> #> $`4` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_4" #> #> $`5` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_5" #> #> $`6` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_6" #> #> $`7` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_7" #> #> $`8` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_8" #> #> $`9` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_9" #> #> $`10` #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//Rtmp6myH4k/file666d3b23b199_split_10" #>