0

I have several hundred files, each of which contain blocks of data, the first block may have seven columns, the second two, the third five, etc. The data in each block differs and contains new column headers. I would like to split each block into a separate data frame.

r2evans
  • 141,215
  • 6
  • 77
  • 149
JAC
  • 1
  • 1
  • 1
    How are you currently reading the data from the file? Is there any sort of delimiter/separator between the 'blocks'? – norie Mar 22 '21 at 18:44
  • 1
    Welcome to SO, JAC! I suspect that this question has been asked-and-answered several times, but it's difficult to know which of the other answers to provide as a reference for you. Your question is lacking details that would help us in that fashion, in that it makes no effort at being *reproducible* so that we can help. In that end, up front: code attempted, sample data (e.g., first few lines of 2-4 files), and expected output. See: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. Thanks! – r2evans Mar 22 '21 at 19:26
  • Data is separated by blank line between blocks – JAC Mar 23 '21 at 00:04
  • df.data <- fread(infile, fill=TRUE). Data Blocks are separated by a blank line. Read works fine as long as the number of columns stays below the initial 12. Last block has 13 – JAC Mar 23 '21 at 00:06

0 Answers0