[Top][All Lists]

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

Re: [FR] ob-awk.el specifying a delimeter argument in for output

From: Max Nikulin
Subject: Re: [FR] ob-awk.el specifying a delimeter argument in for output
Date: Mon, 6 Mar 2023 17:00:54 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1

On 05/03/2023 16:50, Jeremie Juste wrote:
#+begin_src awk :in-file test.csv :cmd-line -F ","
{print $0}

Notice that awk has Output Field Separator that is space by default and may be set using -v OFS=; (or --assign) command line options. -F option sets input field separator FS variable.

"print $0" just sends input record to output literally. If you try to modify some field then record is rebuilt taken into account OFS

    echo 1,2 | awk -F , '{ $1=$1+10; print; }'

    11 2

See (info "(awk) Changing Fields)")
I just have found this link on stackoverflow. It is enough to add even $1=$1 that should not really modify field values.

So I expect less issues with a more realistic example.

As to ";" as CSV values separator, it often appears with "," as decimal separator 1234,56 and dd.mm.yyyy date formats. Unfortunately handling of localized data formats is not a strong side of Emacs. E.g. fixed LC_NUMERIC=C forces "." as decimal separator, date parsing functions are rather limited.

reply via email to

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