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.
To CSV File
Since you are open to other languages, I suggest a solution in Python. It produces a csv file looking like this:
The Code
This makes two assumptions: (1) The first line in the file, or any line following a blank line is a station name and (2) Fields are separated by two or more spaces