bug-datamash
[Top][All Lists]
Advanced

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

Re: Numerical field labels and --header-in


From: Shawn Wagner
Subject: Re: Numerical field labels and --header-in
Date: Wed, 25 May 2022 01:35:36 -0700

Good find. Given that there's already a way to differentiate numerically named columns from positions, I don't think there's any need to change the current behavior.

On Sat, May 21, 2022 at 10:04 AM Erik Auerswald <auerswal@unix-ag.uni-kl.de> wrote:
Hi,

On 20.05.22 06:13, Tim Rice wrote:
>>  0    1   2
>>  1.1 2.2 3.3
>>
>> Then 'datamash --header-in sum 1' returns 1.1 and NOT 2.2. This sucks.
>
> Oh yeah, good catch.
>
>> If header names are available, those thould be the only way to reference
>> fields.
>
> I'm afraid this would break a lot of backwards compatibility.

The info documentation describes this and provides the correct
syntax to reference a number from the header line as field name:

    "Field names must be escaped with a backslash if they start with a
     digit or contain special characters (dash/minus, colons, commas)."

     $ printf '0\t1\t2\n1.1\t2.2\t3.3\n'
     0       1       2
     1.1     2.2     3.3
     $ printf '0\t1\t2\n1.1\t2.2\t3.3\n' \
     > | env LC_NUMERIC=C ./datamash --header-in sum 1
     1.1
     $ printf '0\t1\t2\n1.1\t2.2\t3.3\n' \
     > | env LC_NUMERIC=C ./datamash --header-in sum \\1
     2.2

Thus I'd say this behavior should not be changed.

Thanks,
Erik


reply via email to

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