I am reading in a CSV file into R that contains multiple sections, the sections contain different headers, number of rows and columns. Example table below, I need to separate them into different data frames so I can process them based on the section type.
The number of sections can change and so far I have only figured out how to hard code them and use grep to split the different sections into different data frames.
The sections are all in the same format ==XY== where X is a letter and Y is a number
Is there a better way to split the data frame into a different data frame for each section no matter how many sections there are?
z1 <- structure(list(V1 = c("==C5===", "H1", "1", "3", "8", "==E5===",
"H1", "10", "2", "==G6===", "H1", "5", "==H4===", "H1", "1",
"==H6===", "H1", "10"), V2 = c("", "H2", "9", "8", "1", "", "H2",
"4", "2", "", "", "", "", "H2", "8", "", "", ""), V3 = c("",
"H3", "2", "5", "6", "", "", "", "", "", "", "", "", "", "",
"", "", "")), class = "data.frame", row.names = c(NA, -18L))
DF1 <- z1[grep("==C5", z1$V1):grep("==E5", z1$V1),]
DF2 <- z1[grep("==E5", z1$V1):grep("==G6", z1$V1),]
DF3 <- z1[grep("==G6", z1$V1):grep("==H4", z1$V1),]
DF4 <- z1[grep("==H4", z1$V1):grep("==H6", z1$V1),]
DF5 <- z1[grep("==H6", z1$V1):nrow(z1),]