Алгоритм фильтрации текстовых файлов

Представьте, что у вас есть файл .txt следующей структуры:

>>> header
>>> header
>>> header
K L M
200 0.1 1
201 0.8 1
202 0.01 3
...
800 0.4 2
>>> end of file
50 0.1 1
75 0.78 5
...

Я хотел бы прочитать все данные, кроме строк, обозначенных >>> и строки под строкой >>> конец файла . So far I've solved this using read.table(comment.char = ">", skip = x, nrow = y) (x and y are currently fixed). This reads the data between the header and >>> end of file.

However, I would like to make my function a bit more plastic regarding the number of rows. Data may have values larger than 800, and consequently more rows.

I could scan or readLines the file and see which row corresponds to the >>> end of file and calculate the number of lines to be read. What approach would you use?

11
задан Jørgen R 13 February 2015 в 11:07
поделиться