If you are on MAC or Linux, it's simple to write a command line script to strip everything down to the header line and concatenate it to a single file. It might even be possible on Window's powershell, but I haven't used it.
The R
alternate is to use readLines
{base} to bring in the file and then use stringr
to filter out all lines that don't begin with a numeric. Then you would write it back as a csv, import it back with readr
and use colnames
to add back in the headers. It will be more complicated if any of the preheader summaries begin with a numeric.
Once that's working for a single file, iterating over csv files in a single directory is fairly straightforward and we can continue the discussion.
If you get stuck with parsing the summaries, you should post a reproducible example, called a reprex so that more specific help can be offered.