title: Create a for-loop to read big data in chunks and create new columns
body: <p>I am new to programming with R.</p>
  
  <p>I am trying to write a loop in which reads chuck of data separately (as the size of data is 20GB with 300 million rows) and performs a code to create columns for dates and write it out each chunk as a csv file in each folder. The following is a trial which was suggested by another member. It works smoothly but the only problem is that I am not able to write each chunk in the same loop once it performs the process.</p>
  
  <pre><code>index = 0
  nrows = length(count.fields("RM.csv", sep = ",")) 
  df = vector('list',ceiling(nrows/2)) 
  col_names = colnames(read.csv('RM.csv', nrow=1, header = T))
  end_found=FALSE
  
  while(!end_found)
  {
    begin = 1000*index
    end = min(nrows,begin+1000)
    print(paste0("Reading rows ", begin+1 ," to ", end ))
    df[[index+1]] = fread('RM.csv',skip = begin, nrows =end-begin,
                          col.names = col_names)
    index = index+1
    if(end==nrows) end_found=TRUE
    df = do.call(as.data.frame,df)
    write.csv(df,file = paste0('test1',index,'.csv'))
  }
  </code></pre>
  
  <p>Data:</p>
  
  <pre><code>RM.csv:
          Date
      1   7/30/2017 19:16
      2   7/30/2017 19:05
      3   7/30/2017 19:03
      4   7/30/2017 19:37
      5   7/30/2017 18:36
      6   7/30/2017 20:08
      7   7/30/2017 19:00
      8   7/30/2017 19:21
      9   7/30/2017 17:01
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>    Date    Month   Year
  1   7/30/2017 19:16 Jul-17  2017
  2   7/30/2017 19:05 Jul-17  2017
  3   7/30/2017 19:03 Jul-17  2017
  4   7/30/2017 19:37 Jul-17  2017
  5   7/30/2017 18:36 Jul-17  2017
  6   7/30/2017 20:08 Jul-17  2017
  7   7/30/2017 19:00 Jul-17  2017
  8   7/30/2017 19:21 Jul-17  2017
  9   7/30/2017 17:01 Jul-17  2017
  </code></pre>