Skip to content

Scanning data files line-by-line

2 messages · R A F, Duncan Murdoch

#
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!
#
On Wed, 30 Apr 2003 18:06:56 +0000, you wrote in message
<Law11-F85PZGGxWalhX00017a85 at hotmail.com>:
...
I'd try working with the fill=TRUE option, and give excess fields in
your list.

Duncan Murdoch