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.
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