[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CSV extension status

From: Manuel Collado
Subject: Re: CSV extension status
Date: Wed, 19 May 2021 20:01:30 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

El 19/05/2021 a las 15:44, Andrew J. Schorr escribió:
On Wed, May 19, 2021 at 09:03:36AM -0400, Andrew J. Schorr wrote:
         _csv_nf = csvsplit($0, _csv_ff)
         _csv_record = ""
         _csv_sep = ""
         for (k=1; k in _csv_ff; k++) {
             _csv_record = _csv_record _csv_sep csvunquote(_csv_ff[k])
             _csv_sep = OFS
         $0 = _csv_record

Why is this written as:

        for (k=1; k in _csv_ff; k++) {

instead of:

        for (k=1; k <= _csv_nf; k++) {

Unless I'm confused, the latter ought to be faster (simple arithmetic
comparison instead of a hash lookup).

Right. It is a matter of style. The former can be used when the number of elements is not explicitly stated. Well, it would suffice to call length(array). Not available in older awks.

Manuel Collado - http://mcollado.z15.es

reply via email to

[Prev in Thread] Current Thread [Next in Thread]