Skip to Content

How to convert structured text to data columns in R?

I have a fairly large (1000 pages) list of structured text which I would like to convert into a data frame (preferably using R, but I am open to suggestions).

The text file looks as follows:

AC-Acrelândia
TV    Canal 18    AINDA NÃO OUTORGADO
RTV  Canal 9    RADIO TV DO AMAZONAS LTDA
RTV  Canal 10    RADIO TV DO AMAZONAS LTDA(REDENCAO)
TVD  Canal 15    RADIO TV DO AMAZONAS LTDA
TVD  Canal 15    AINDA NÃO OUTORGADO(REDENÇÃO)
FM   88,5 MHz   RADIO E TV MAIRA LTDA
 
AC-Assis Brasil
TV    Canal 34    AINDA NÃO OUTORGADO
RTV  Canal 6    AMAZONIA CABO LTDA
RTV  Canal 10    RADIO TV DO AMAZONAS LTDA
RTV  Canal 13    AINDA NÃO OUTORGADO
RTV  Canal 45    FUNDACAO JOAO PAULO II

and I would like to convert it into something like this:

AC  Acrelândia    TV    Canal 18    AINDA NÃO OUTORGADO
AC  Acrelândia    RTV   Canal 9     RADIO TV DO AMAZONAS LTDA
AC  Acrelândia    RTV   Canal 10    RADIO TV DO AMAZONAS LTDA(REDENCAO)
....

It seems readLines() is a good start, but I am having a hard time with the structure.