Skip to content
Prev 31438 / 398506 Next

Scanning data files line-by-line

I'm sorry to have to ask another question related to this.  What if
the lines have variable number of fields?

For example, all I know is that each line starts with double, string,
double, say, but some lines may have some more fields afterwards.  So
the data file may look like

1 A 2
3 B 4 5
6   DD 7
etc.

If I use scan with list( 0, "", 0 ), each line is treated as if it
has a multiple of 3 elements, but really, what I want is to discard
all fields after the third.

I tried the nmax = 3 option but that did not seem to work.  Maybe I'm
doing this wrong.

Thanks again!