I am trying to import a series of custom data files into R.
The files are organized into blocks, which are marked by XML-like markup tags. I understand that these files are not true XML-files and they contain no definition of markup language.
Each block may be a single line or a tab delimited matrix. Comments tend to be marked by a %
The files are ~10K lines long and I need around 2700 lines from each of them, so I would rather want to avoid loops. Also the file length and number of needed lines varies by somewhat unpredictable factors.
I have tried a number of the methods from the XML package, but always get bunch of errors such as "StartTag: invalid element name" and "Premature end of data in tag MERGED-PUPIL-DATA line 5443".
Do you have any ideas? Are there any methods that accept custom markup tags?
A typical file may look something like this (dots indicate stuff I cut out)
<SESSION>
<VERSION>
2
<\VERSION>
<DATE>
2014-01-20 14:29:43
<\DATE>
<SUBJECT-ID>
SUB001
<\SUBJECT-ID>
<NOTE>
red300os
<\NOTE>
<MIN-MAX-PLOT>
0.100000 8707.554688
<\MIN-MAX-PLOT>
<STIMULUS-DEFINED>
redOS300
Default Human Relative Spectral Sensitivity
1 0
1 10.000000 20.000000 60.000000 1 3 2.000000 -100.000000 0.000000 0.000000 1
<\STIMULUS-DEFINED>
.
.
.
.
.
.
<MERGED-PUPIL-DATA>
% time is in sec; diameter is in mm; loci is in pixel; color code -> 100 = unknown, 0 = white, 1 = red, 2 = green, 3 = blue; intensity is in Lux or W/m2
% real time logical time R. valid R. diameter R. x loci R. y loci L. valid L. diameter L. x loci L. y loci R. led color R. led intensity L. led color L. led intensity
2703
-0.049000 -0.049000 1 5.483765 266.668732 268.837402 1 5.441666 272.687500 272.724976 100 0.000000 100 0.000000
-0.018000 -0.018000 1 5.478448 265.918732 267.837402 1 5.438361 270.687500 273.406219 100 0.000000 100 0.000000
.
.
.
.
89.932000 89.932000 1 5.604879 289.575165 273.574738 1 5.255306 301.056091 303.812744 3 0.000000 3 0.000000
89.964000 89.964000 1 5.650856 289.575165 269.574738 1 5.255306 301.056091 301.812744 3 0.000000 3 0.000000
<\MERGED-PUPIL-DATA>
.
.
.
<\SESSION>