Sujet : Re: [gawk] Handling variants of CSV input data formats
De : mortonspam (at) *nospam* gmail.com (Ed Morton)
Groupes : comp.lang.awkDate : 27. Aug 2024, 01:49:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vaj7ps$2lph3$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 8/26/2024 7:54 AM, Janis Papanagnou wrote:
snip>
I'd have liked to provide more concrete information here, but I'm at
the moment even unable to reproduce Awk's behavior as documented in
its manual; I've tried the following command with various locales
$ echo 4,321 | LC_ALL=en_DK.utf-8 gawk '{ print $1 + 1 }'
-| 5,321
but always got just 5 as result.
You need to specifically TELL gawk to use your locale to read input numbers:
$ echo 4,321 | LC_ALL=en_DK.utf-8 gawk '{ print $1 + 1 }'
5
$ echo 4,321 | POSIXLY_CORRECT=1 LC_ALL=en_DK.utf-8 gawk '{ print $1 + 1 }'
5,321
$ echo 4,321 | LC_ALL=en_DK.utf-8 gawk -N '{ print $1 + 1 }' 5,321
See
https://www.gnu.org/software/gawk/manual/gawk.html#Locale-influences-conversions for more info on that.
Regards,
Ed